ConfidentialClient
The ConfidentialClient wraps Token-2022’s Confidential Transfer extension, providing account configuration, deposits, withdrawals, and balance management with encrypted balances.
Account Configuration
Before an account can send or receive confidential transfers, it must be configured with an ElGamal keypair:
This:
- Derives deterministic ElGamal and AES keys from the owner keypair + mint
- Generates a pubkey validity proof (via WASM)
- Submits the configuration transaction
Deposit
Move tokens from the public balance into the confidential balance:
Apply Pending Balance
Incoming confidential transfers accumulate in a pending balance. Apply them to the available balance:
After receiving MAX_PENDING_BALANCE_CREDIT_COUNTER (65,536) incoming transfers, you must apply the pending balance before receiving more.
Withdraw
Move tokens from the confidential balance back to the public balance:
Balance Queries
getConfidentialAccountState(tokenAccount)
getDecryptableBalance(tokenAccount, ownerKeypair, mint)
Decrypt the current available confidential balance:
Credit Controls
enableConfidentialCredits(tokenAccount)
Allow the account to receive confidential transfers.
disableConfidentialCredits(tokenAccount)
Block incoming confidential transfers.
enableNonConfidentialCredits(tokenAccount)
Allow the account to receive non-confidential (public) transfers.
disableNonConfidentialCredits(tokenAccount)
Block incoming non-confidential transfers.
Cryptographic Functions
These standalone functions are also exported for advanced usage:
Key Derivation
Keys are derived deterministically from the owner keypair and mint address, so they can be re-derived without storage.
Encryption & Decryption
Proof Generation
Amount Limits
Confidential transfers are limited to amounts representable in 48 bits:
max_amount=248−1=281,474,976,710,655
With 6 decimals, this is approximately 281 billion tokens — more than sufficient for any practical use.