@@ -57,19 +57,19 @@ use {
57
57
transfer_hook:: TransferHook ,
58
58
BaseStateWithExtensions , ExtensionType , StateWithExtensionsOwned ,
59
59
} ,
60
- solana_zk_token_sdk:: {
61
- encryption:: {
62
- auth_encryption:: AeKey ,
63
- elgamal:: { self , ElGamalKeypair } ,
64
- } ,
65
- zk_token_elgamal:: pod:: ElGamalPubkey ,
60
+ solana_zk_sdk:: encryption:: {
61
+ auth_encryption:: AeKey ,
62
+ elgamal:: { self , ElGamalKeypair } ,
63
+ pod:: elgamal:: PodElGamalPubkey ,
66
64
} ,
67
65
state:: { Account , AccountState , Mint } ,
68
66
} ,
69
67
spl_token_client:: {
70
68
client:: { ProgramRpcClientSendTransaction , RpcClientResponse } ,
71
- proof_generation:: ProofAccount ,
72
- token:: { ComputeUnitLimit , ExtensionInitializationParams , Token } ,
69
+ token:: { ComputeUnitLimit , ExtensionInitializationParams , ProofAccount , Token } ,
70
+ } ,
71
+ spl_token_confidential_transfer_proof_generation:: {
72
+ transfer:: TransferProofData , withdraw:: WithdrawProofData ,
73
73
} ,
74
74
spl_token_group_interface:: state:: TokenGroup ,
75
75
spl_token_metadata_interface:: state:: { Field , TokenMetadata } ,
@@ -1479,7 +1479,7 @@ async fn command_transfer(
1479
1479
let auditor_elgamal_pubkey = if let Ok ( confidential_transfer_mint) =
1480
1480
mint_state. get_extension :: < ConfidentialTransferMint > ( )
1481
1481
{
1482
- let expected_auditor_elgamal_pubkey = Option :: < ElGamalPubkey > :: from (
1482
+ let expected_auditor_elgamal_pubkey = Option :: < PodElGamalPubkey > :: from (
1483
1483
confidential_transfer_mint. auditor_elgamal_pubkey ,
1484
1484
) ;
1485
1485
@@ -1589,35 +1589,41 @@ async fn command_transfer(
1589
1589
. unwrap ( ) ;
1590
1590
let transfer_account_info = TransferAccountInfo :: new ( extension) ;
1591
1591
1592
- let ( equality_proof_data, ciphertext_validity_proof_data, range_proof_data) =
1593
- transfer_account_info
1594
- . generate_split_transfer_proof_data (
1595
- transfer_balance,
1596
- & args. sender_elgamal_keypair ,
1597
- & args. sender_aes_key ,
1598
- & recipient_elgamal_pubkey,
1599
- auditor_elgamal_pubkey. as_ref ( ) ,
1600
- )
1601
- . unwrap ( ) ;
1592
+ let TransferProofData {
1593
+ equality_proof_data,
1594
+ ciphertext_validity_proof_data,
1595
+ range_proof_data,
1596
+ } = transfer_account_info
1597
+ . generate_split_transfer_proof_data (
1598
+ transfer_balance,
1599
+ & args. sender_elgamal_keypair ,
1600
+ & args. sender_aes_key ,
1601
+ & recipient_elgamal_pubkey,
1602
+ auditor_elgamal_pubkey. as_ref ( ) ,
1603
+ )
1604
+ . unwrap ( ) ;
1602
1605
1603
1606
// setup proofs
1604
1607
let _ = try_join ! (
1605
- token. create_range_proof_context_state_for_transfer (
1608
+ token. confidential_transfer_create_context_state_account (
1606
1609
& range_proof_pubkey,
1607
1610
& context_state_authority_pubkey,
1608
1611
& range_proof_data,
1612
+ true ,
1609
1613
& range_proof_context_state_account,
1610
1614
) ,
1611
- token. create_equality_proof_context_state_for_transfer (
1615
+ token. confidential_transfer_create_context_state_account (
1612
1616
& equality_proof_pubkey,
1613
1617
& context_state_authority_pubkey,
1614
1618
& equality_proof_data,
1619
+ false ,
1615
1620
& equality_proof_context_state_account,
1616
1621
) ,
1617
- token. create_ciphertext_validity_proof_context_state_for_transfer (
1622
+ token. confidential_transfer_create_context_state_account (
1618
1623
& ciphertext_validity_proof_pubkey,
1619
1624
& context_state_authority_pubkey,
1620
1625
& ciphertext_validity_proof_data,
1626
+ false ,
1621
1627
& ciphertext_validity_proof_context_state_account,
1622
1628
)
1623
1629
) ?;
@@ -2944,7 +2950,7 @@ async fn command_update_confidential_transfer_settings(
2944
2950
let new_auditor_pubkey = if let Some ( auditor_pubkey) = auditor_pubkey {
2945
2951
auditor_pubkey. into ( )
2946
2952
} else {
2947
- Option :: < ElGamalPubkey > :: from ( confidential_transfer_mint. auditor_elgamal_pubkey )
2953
+ Option :: < PodElGamalPubkey > :: from ( confidential_transfer_mint. auditor_elgamal_pubkey )
2948
2954
} ;
2949
2955
2950
2956
( new_auto_approve, new_auditor_pubkey)
@@ -3335,28 +3341,47 @@ async fn command_deposit_withdraw_confidential_tokens(
3335
3341
let withdraw_account_info = WithdrawAccountInfo :: new ( extension_state) ;
3336
3342
3337
3343
let context_state_authority = config. fee_payer ( ) ?;
3338
- let context_state_keypair = Keypair :: new ( ) ;
3339
- let context_state_pubkey = context_state_keypair. pubkey ( ) ;
3344
+ let equality_proof_context_state_keypair = Keypair :: new ( ) ;
3345
+ let equality_proof_context_state_pubkey = equality_proof_context_state_keypair. pubkey ( ) ;
3346
+ let range_proof_context_state_keypair = Keypair :: new ( ) ;
3347
+ let range_proof_context_state_pubkey = range_proof_context_state_keypair. pubkey ( ) ;
3340
3348
3341
- let withdraw_proof_data =
3342
- withdraw_account_info. generate_proof_data ( amount, elgamal_keypair, aes_key) ?;
3349
+ let WithdrawProofData {
3350
+ equality_proof_data,
3351
+ range_proof_data,
3352
+ } = withdraw_account_info. generate_proof_data ( amount, elgamal_keypair, aes_key) ?;
3343
3353
3344
- // setup proof
3345
- token
3346
- . create_withdraw_proof_context_state (
3347
- & context_state_pubkey,
3348
- & context_state_authority. pubkey ( ) ,
3349
- & withdraw_proof_data,
3350
- & context_state_keypair,
3354
+ // set up context state accounts
3355
+ let context_state_authority_pubkey = context_state_authority. pubkey ( ) ;
3356
+
3357
+ let _ = try_join ! (
3358
+ token. confidential_transfer_create_context_state_account(
3359
+ & equality_proof_context_state_pubkey,
3360
+ & context_state_authority_pubkey,
3361
+ & equality_proof_data,
3362
+ false ,
3363
+ & equality_proof_context_state_keypair,
3364
+ ) ,
3365
+ token. confidential_transfer_create_context_state_account(
3366
+ & range_proof_context_state_pubkey,
3367
+ & context_state_authority_pubkey,
3368
+ & range_proof_data,
3369
+ true ,
3370
+ & range_proof_context_state_keypair,
3351
3371
)
3352
- . await ?;
3372
+ ) ?;
3353
3373
3354
3374
// do the withdrawal
3355
- token
3375
+ let withdraw_result = token
3356
3376
. confidential_transfer_withdraw (
3357
3377
& token_account_address,
3358
3378
& owner,
3359
- Some ( & ProofAccount :: ContextAccount ( context_state_pubkey) ) ,
3379
+ Some ( & ProofAccount :: ContextAccount (
3380
+ equality_proof_context_state_pubkey,
3381
+ ) ) ,
3382
+ Some ( & ProofAccount :: ContextAccount (
3383
+ range_proof_context_state_pubkey,
3384
+ ) ) ,
3360
3385
amount,
3361
3386
decimals,
3362
3387
Some ( withdraw_account_info) ,
@@ -3367,15 +3392,22 @@ async fn command_deposit_withdraw_confidential_tokens(
3367
3392
. await ?;
3368
3393
3369
3394
// close context state account
3370
- let context_state_authority_pubkey = context_state_authority. pubkey ( ) ;
3371
- token
3372
- . confidential_transfer_close_context_state (
3373
- & context_state_pubkey,
3395
+ let _ = try_join ! (
3396
+ token. confidential_transfer_close_context_state(
3397
+ & equality_proof_context_state_pubkey,
3398
+ & token_account_address,
3399
+ & context_state_authority_pubkey,
3400
+ & context_state_authority,
3401
+ ) ,
3402
+ token. confidential_transfer_close_context_state(
3403
+ & range_proof_context_state_pubkey,
3374
3404
& token_account_address,
3375
3405
& context_state_authority_pubkey,
3376
3406
& context_state_authority,
3377
3407
)
3378
- . await ?
3408
+ ) ?;
3409
+
3410
+ withdraw_result
3379
3411
}
3380
3412
} ;
3381
3413
@@ -3447,8 +3479,8 @@ async fn command_apply_pending_balance(
3447
3479
struct ConfidentialTransferArgs {
3448
3480
sender_elgamal_keypair : ElGamalKeypair ,
3449
3481
sender_aes_key : AeKey ,
3450
- recipient_elgamal_pubkey : Option < ElGamalPubkey > ,
3451
- auditor_elgamal_pubkey : Option < ElGamalPubkey > ,
3482
+ recipient_elgamal_pubkey : Option < PodElGamalPubkey > ,
3483
+ auditor_elgamal_pubkey : Option < PodElGamalPubkey > ,
3452
3484
}
3453
3485
3454
3486
pub async fn process_command < ' a > (
0 commit comments