[token-cli] Add --decrypt flag to display for confidential balances - #1394
Open
AyushAgrawal-A2 wants to merge 1 commit into
Open
[token-cli] Add --decrypt flag to display for confidential balances#1394AyushAgrawal-A2 wants to merge 1 commit into
--decrypt flag to display for confidential balances#1394AyushAgrawal-A2 wants to merge 1 commit into
Conversation
Adds `spl-token display --decrypt [--owner <KEYPAIR>]` which derives the ElGamal/AES keys from the signer, verifies they match the on-chain encryption key (falling back to the legacy KDF), and shows the decrypted pending/available balances of a token account or the confidential supply of a confidential mint-burn mint. Also renders the previously hidden `ConfidentialMintBurn` extension section. Fixes solana-program#145 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
spl-token displayonly shows the ciphertexts of confidential transfer balances; there is no way to see the decrypted pending/available balance (or the confidential supply of a mint-burn mint) from the CLI.Fixes #145
Summary of changes
--decrypt(and--owner <KEYPAIR>) tospl-token display.derive_confidential_keys(same as the other confidential commands, no raw key argument). The derived ElGamal pubkey is checked against the on-chain one before decrypting, with a fallback to the legacy pre-HKDF derivation; a mismatch produces a clear error instead of a slow failing discrete-log search.ApplyPendingBalanceAccountInfo::get_pending_balance) and available balance (AES viaget_available_balance), shown asDecrypted Pending Balance/Decrypted Available Balanceunder theConfidential transfer:section and asdecryptedConfidentialBalancesin JSON output.ConfidentialMintBurn: decrypts the supply viaSupplyAccountInfo::decrypted_current_supply, shown asDecrypted Supply/decryptedConfidentialSupply.ConfidentialMintBurnextension indisplay(previously fell through to_ => Ok(())).confidential_transfer(after deposit, apply, transfer, withdraw; wrong signer errors; no field without--decrypt) andconfidential_mint_burn(supply after mint, text-mode section rendering).Notes:
--decryptis documented as owner/supply-authority only.SupplyAccountInfo::decrypted_current_supplycan only recover the supply while the decryptable supply is within 2^32 base units of the ElGamal supply (burns don't update the decryptable supply). After larger applied burnsdisplay --decrypton the mint returns an explanatory error; the CLI's confidentialminthas the same pre-existing limitation.Example:
🤖 Generated with Claude Code