3939 error:: TokenError ,
4040 extension:: {
4141 confidential_mint_burn:: {
42- instruction:: BurnSplitContextStateAccounts ,
43- proof_generation :: { generate_burn_proofs , generate_mint_proofs } ,
42+ instruction:: { BurnSplitContextStateAccounts , MintSplitContextStateAccounts } ,
43+ ConfidentialMintBurn ,
4444 } ,
4545 confidential_transfer:: {
4646 account_info:: {
6262 transfer_hook:: TransferHook ,
6363 BaseStateWithExtensions , ExtensionType , StateWithExtensionsOwned ,
6464 } ,
65- proof:: ProofLocation ,
6665 solana_zk_sdk:: encryption:: {
6766 auth_encryption:: AeKey ,
6867 elgamal:: { self , ElGamalKeypair } ,
7574 token:: { ComputeUnitLimit , ExtensionInitializationParams , ProofAccount , Token } ,
7675 } ,
7776 spl_token_confidential_transfer_proof_generation:: {
78- transfer:: TransferProofData , withdraw:: WithdrawProofData ,
77+ burn:: burn_split_proof_data, mint:: mint_split_proof_data, transfer:: TransferProofData ,
78+ withdraw:: WithdrawProofData ,
7979 } ,
8080 spl_token_group_interface:: state:: TokenGroup ,
8181 spl_token_metadata_interface:: state:: { Field , TokenMetadata } ,
@@ -3444,59 +3444,100 @@ async fn command_deposit_withdraw_mint_confidential_tokens(
34443444 }
34453445 ConfidentialInstructionType :: Mint => {
34463446 let payer = config. fee_payer ( ) ?;
3447- let range_proof_context_state_account = Keypair :: new ( ) ;
3448- let range_proof_context_pubkey = range_proof_context_state_account. pubkey ( ) ;
3447+
3448+ let equality_proof_context_state_account = Keypair :: new ( ) ;
3449+ let equality_proof_context_pubkey = equality_proof_context_state_account. pubkey ( ) ;
34493450 let ciphertext_validity_proof_context_state_account = Keypair :: new ( ) ;
34503451 let ciphertext_validity_proof_context_pubkey =
34513452 ciphertext_validity_proof_context_state_account. pubkey ( ) ;
3453+ let range_proof_context_state_account = Keypair :: new ( ) ;
3454+ let range_proof_context_pubkey = range_proof_context_state_account. pubkey ( ) ;
34523455
34533456 let mint_to_elgamal_pubkey =
34543457 token. account_elgamal_pubkey ( & token_account_address) . await ?;
34553458 let auditor_elgamal_pubkey = token. auditor_elgamal_pubkey ( ) . await ?;
34563459 let supply_elgamal_pubkey = token. supply_elgamal_pubkey ( ) . await ?;
34573460
3458- let ( range_proof, ciphertext_validity_proof, pedersen_openings) = generate_mint_proofs (
3461+ let dummy_elgamal = ElGamalKeypair :: new_rand ( ) ;
3462+ let dummy_aes = AeKey :: new_rand ( ) ;
3463+ let supply_elgamal_keypair = match elgamal_keypair {
3464+ Some ( e) => e,
3465+ None => {
3466+ // if no ElGamalKeypair supplied just use a dummy for
3467+ // proof creation
3468+ & dummy_elgamal
3469+ }
3470+ } ;
3471+ let supply_aes_key = match aes_key {
3472+ Some ( e) => e,
3473+ None => {
3474+ // see above
3475+ & dummy_aes
3476+ }
3477+ } ;
3478+
3479+ let mint = token. get_mint_info ( ) . await ?;
3480+ let conf_mb_ext = mint. get_extension :: < ConfidentialMintBurn > ( ) ?;
3481+
3482+ let context_state_accounts = MintSplitContextStateAccounts {
3483+ equality_proof : & equality_proof_context_pubkey,
3484+ ciphertext_validity_proof : & ciphertext_validity_proof_context_pubkey,
3485+ range_proof : & range_proof_context_pubkey,
3486+ authority : & payer. pubkey ( ) ,
3487+ } ;
3488+
3489+ let proof_data = mint_split_proof_data (
3490+ & conf_mb_ext
3491+ . confidential_supply
3492+ . try_into ( )
3493+ . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
3494+ & conf_mb_ext
3495+ . decryptable_supply
3496+ . try_into ( )
3497+ . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
34593498 amount,
3499+ supply_elgamal_keypair,
3500+ supply_aes_key,
34603501 & mint_to_elgamal_pubkey,
3461- & auditor_elgamal_pubkey,
3462- & supply_elgamal_pubkey,
3502+ & auditor_elgamal_pubkey. unwrap_or_default ( ) ,
34633503 ) ?;
34643504
3505+ let equality_proof_signer = & [ & equality_proof_context_state_account] ;
3506+ let ciphertext_validity_proof_signer =
3507+ & [ & ciphertext_validity_proof_context_state_account] ;
34653508 let range_proof_signer = & [ & range_proof_context_state_account] ;
3466- let ciphertext_validity_proof_signer = & [ & ciphertext_validity_proof_context_state_account] ;
34673509 let context_state_auth = payer. pubkey ( ) ;
34683510 let _ = try_join ! (
34693511 token. confidential_transfer_create_context_state_account(
3470- & range_proof_context_pubkey ,
3512+ & equality_proof_context_pubkey ,
34713513 & context_state_auth,
3472- & range_proof ,
3514+ & proof_data . equality_proof_data ,
34733515 true ,
3474- range_proof_signer ,
3516+ equality_proof_signer ,
34753517 ) ,
34763518 token. confidential_transfer_create_context_state_account(
34773519 & ciphertext_validity_proof_context_pubkey,
34783520 & context_state_auth,
3479- & ciphertext_validity_proof ,
3521+ & proof_data . ciphertext_validity_proof_data ,
34803522 false ,
34813523 ciphertext_validity_proof_signer,
34823524 ) ,
3525+ token. confidential_transfer_create_context_state_account(
3526+ & range_proof_context_pubkey,
3527+ & context_state_auth,
3528+ & proof_data. range_proof_data,
3529+ true ,
3530+ range_proof_signer,
3531+ ) ,
34833532 ) ?;
34843533
3485- let range_proof_location =
3486- ProofLocation :: ContextStateAccount ( & range_proof_context_pubkey) ;
3487- let ciphertext_validity_proof_location =
3488- ProofLocation :: ContextStateAccount ( & ciphertext_validity_proof_context_pubkey) ;
3489-
34903534 let res = token
34913535 . confidential_mint (
34923536 & token_account_address,
34933537 & owner,
3494- amount,
3495- auditor_elgamal_pubkey,
34963538 supply_elgamal_pubkey,
3497- range_proof_location,
3498- ciphertext_validity_proof_location,
3499- & pedersen_openings,
3539+ & context_state_accounts,
3540+ proof_data. new_decryptable_supply ,
35003541 & bulk_signers,
35013542 )
35023543 . await ?;
@@ -4911,50 +4952,49 @@ async fn command_confidential_burn(
49114952 . unwrap ( ) ;
49124953 let transfer_account_info = TransferAccountInfo :: new ( extension) ;
49134954
4914- let ( equality_proof_data, ciphertext_validity_proof_data, range_proof_data, pedersen_openings) =
4915- generate_burn_proofs (
4916- & transfer_account_info
4917- . available_balance
4918- . try_into ( )
4919- . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
4920- & transfer_account_info
4921- . decryptable_available_balance
4922- . try_into ( )
4923- . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
4924- burn_amount,
4925- elgamal_keypair,
4926- aes_key,
4927- & auditor_elgamal_pubkey,
4928- & supply_elgamal_pubkey,
4929- )
4930- . unwrap ( ) ;
4955+ let proof_data = burn_split_proof_data (
4956+ & transfer_account_info
4957+ . available_balance
4958+ . try_into ( )
4959+ . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
4960+ & transfer_account_info
4961+ . decryptable_available_balance
4962+ . try_into ( )
4963+ . map_err ( |_| TokenError :: MalformedCiphertext ) ?,
4964+ burn_amount,
4965+ elgamal_keypair,
4966+ aes_key,
4967+ & auditor_elgamal_pubkey. unwrap_or_default ( ) ,
4968+ & supply_elgamal_pubkey. unwrap_or_default ( ) ,
4969+ )
4970+ . unwrap ( ) ;
49314971
49324972 let range_proof_signer = & [ & range_proof_context_state_account] ;
49334973 let equality_proof_signer = & [ & equality_proof_context_state_account] ;
49344974 let ciphertext_validity_proof_signer = & [ & ciphertext_validity_proof_context_state_account] ;
49354975 // setup proofs
49364976 let _ = try_join ! (
4937- token. confidential_transfer_create_context_state_account(
4938- context_state_accounts. range_proof,
4939- context_state_accounts. authority,
4940- & range_proof_data,
4941- true ,
4942- range_proof_signer,
4943- ) ,
49444977 token. confidential_transfer_create_context_state_account(
49454978 context_state_accounts. equality_proof,
49464979 context_state_accounts. authority,
4947- & equality_proof_data,
4980+ & proof_data . equality_proof_data,
49484981 false ,
49494982 equality_proof_signer,
49504983 ) ,
49514984 token. confidential_transfer_create_context_state_account(
49524985 context_state_accounts. ciphertext_validity_proof,
49534986 context_state_accounts. authority,
4954- & ciphertext_validity_proof_data,
4987+ & proof_data . ciphertext_validity_proof_data,
49554988 false ,
49564989 ciphertext_validity_proof_signer,
49574990 ) ,
4991+ token. confidential_transfer_create_context_state_account(
4992+ context_state_accounts. range_proof,
4993+ context_state_accounts. authority,
4994+ & proof_data. range_proof_data,
4995+ true ,
4996+ range_proof_signer,
4997+ ) ,
49584998 ) ?;
49594999
49605000 // do the burn
@@ -4964,11 +5004,9 @@ async fn command_confidential_burn(
49645004 & authority,
49655005 & context_state_accounts,
49665006 burn_amount,
4967- auditor_elgamal_pubkey,
49685007 supply_elgamal_pubkey,
49695008 aes_key,
49705009 & bulk_signers,
4971- & pedersen_openings,
49725010 )
49735011 . await ?;
49745012
0 commit comments