Skip to content

Commit 3346b41

Browse files
gitteriZYJLiu
andauthored
docs: Rewrite confidential transfer examples for Token-2022 v11 (#1574)
* docs: rewrite confidential transfer examples for Token-2022 v11 Reground the create-token-account, transfer, and withdraw pages in the confidential-balances-exploration reference now that Token-2022 v11 is live on mainnet. Replaces the outdated examples (solana-sdk 2.2 / spl-token-client 0.14, inline proofs) with the v11 context-state-account proof flow. Each page now has both a Rust tab and a TypeScript tab: - Rust: raw instruction builders on the granular v11 crate stack (proofs pre-verified into context state accounts via the ZK ElGamal Proof program). Every example compiles against the v11 reference. - TypeScript: the new helpers from @solana-program/token-2022/confidential (getCreateConfidentialTransferAccountInstructionPlan, getConfidentialTransferInstructionPlan, getConfidentialWithdrawInstructionPlan) with recoverable key derivation. Every example typechecks against the published packages. Also updates the proof-flow prose/diagram and the run instructions: confidential transfers need the ZK ElGamal Proof program, available on mainnet, devnet, and a mainnet-forking local validator like Surfpool, but not the stock solana-test-validator. * docs: add v11 examples for create-mint, deposit, and apply-pending-balance Same v11 treatment as the other confidential transfer pages, completing the set: both a Rust tab and a TypeScript tab, on the granular v11 crate stack. - create-mint: raw initialize-confidential-transfer-mint + initialize-mint (Rust) and getCreateMintInstructionPlan with a ConfidentialTransferMint extension (TS); now configures an auditor rather than passing None. - deposit: the deposit instruction (no proof); public -> pending. - apply-pending-balance: decrypt pending/available, re-encrypt, and apply_pending_balance (Rust); getApplyConfidentialPendingBalanceInstructionFromToken (TS), which does the decrypt/re-encrypt internally. Rust examples compile against the v11 reference; TS examples typecheck against the published packages. Run instructions updated to the same ZK-program note (mainnet, devnet, or a mainnet-forking local validator like Surfpool). * docs: read available balance via AES in withdraw and apply examples Address Greptile review: the withdraw and apply-pending-balance Rust examples read the available balance from the AES-encrypted decryptable_available_balance instead of ElGamal decrypt_u32. decrypt_u32 uses baby-step-giant-step and only recovers values up to 2^32 raw units, so it fails for realistic balances (a 9-decimal token holding a few tokens already exceeds the cap); the AES field has no range limit. Pending lo/hi stay on decrypt_u32 since they are bounded. Both examples still compile against the v11 reference. * update confidential transfer rust examples * update confidential transfer typescript examples * fix apply-pending-balance and withdraw-tokens page * update confidential token transfer TS example * remove zk elgamal program warn callouts * update confidential token transfer example to fetch mint and read auditor elgamal pubkey * greptile fix --------- Co-authored-by: John <75003086+ZYJLiu@users.noreply.github.com>
1 parent 1e68a71 commit 3346b41

7 files changed

Lines changed: 2980 additions & 2645 deletions

File tree

0 commit comments

Comments
 (0)