@@ -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,32 +1589,35 @@ 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,
1609
1612
& range_proof_context_state_account,
1610
1613
) ,
1611
- token. create_equality_proof_context_state_for_transfer (
1614
+ token. confidential_transfer_create_context_state_account (
1612
1615
& equality_proof_pubkey,
1613
1616
& context_state_authority_pubkey,
1614
1617
& equality_proof_data,
1615
1618
& equality_proof_context_state_account,
1616
1619
) ,
1617
- token. create_ciphertext_validity_proof_context_state_for_transfer (
1620
+ token. confidential_transfer_create_context_state_account (
1618
1621
& ciphertext_validity_proof_pubkey,
1619
1622
& context_state_authority_pubkey,
1620
1623
& ciphertext_validity_proof_data,
@@ -2944,7 +2947,7 @@ async fn command_update_confidential_transfer_settings(
2944
2947
let new_auditor_pubkey = if let Some ( auditor_pubkey) = auditor_pubkey {
2945
2948
auditor_pubkey. into ( )
2946
2949
} else {
2947
- Option :: < ElGamalPubkey > :: from ( confidential_transfer_mint. auditor_elgamal_pubkey )
2950
+ Option :: < PodElGamalPubkey > :: from ( confidential_transfer_mint. auditor_elgamal_pubkey )
2948
2951
} ;
2949
2952
2950
2953
( new_auto_approve, new_auditor_pubkey)
@@ -3335,28 +3338,45 @@ async fn command_deposit_withdraw_confidential_tokens(
3335
3338
let withdraw_account_info = WithdrawAccountInfo :: new ( extension_state) ;
3336
3339
3337
3340
let context_state_authority = config. fee_payer ( ) ?;
3338
- let context_state_keypair = Keypair :: new ( ) ;
3339
- let context_state_pubkey = context_state_keypair. pubkey ( ) ;
3341
+ let equality_proof_context_state_keypair = Keypair :: new ( ) ;
3342
+ let equality_proof_context_state_pubkey = equality_proof_context_state_keypair. pubkey ( ) ;
3343
+ let range_proof_context_state_keypair = Keypair :: new ( ) ;
3344
+ let range_proof_context_state_pubkey = range_proof_context_state_keypair. pubkey ( ) ;
3340
3345
3341
- let withdraw_proof_data =
3342
- withdraw_account_info. generate_proof_data ( amount, elgamal_keypair, aes_key) ?;
3346
+ let WithdrawProofData {
3347
+ equality_proof_data,
3348
+ range_proof_data,
3349
+ } = withdraw_account_info. generate_proof_data ( amount, elgamal_keypair, aes_key) ?;
3343
3350
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,
3351
+ // set up context state accounts
3352
+ let context_state_authority_pubkey = context_state_authority. pubkey ( ) ;
3353
+
3354
+ let _ = try_join ! (
3355
+ token. confidential_transfer_create_context_state_account(
3356
+ & equality_proof_context_state_pubkey,
3357
+ & context_state_authority_pubkey,
3358
+ & equality_proof_data,
3359
+ & equality_proof_context_state_keypair,
3360
+ ) ,
3361
+ token. confidential_transfer_create_context_state_account(
3362
+ & range_proof_context_state_pubkey,
3363
+ & context_state_authority_pubkey,
3364
+ & range_proof_data,
3365
+ & range_proof_context_state_keypair,
3351
3366
)
3352
- . await ?;
3367
+ ) ?;
3353
3368
3354
3369
// do the withdrawal
3355
- token
3370
+ let withdraw_result = token
3356
3371
. confidential_transfer_withdraw (
3357
3372
& token_account_address,
3358
3373
& owner,
3359
- Some ( & ProofAccount :: ContextAccount ( context_state_pubkey) ) ,
3374
+ Some ( & ProofAccount :: ContextAccount (
3375
+ equality_proof_context_state_pubkey,
3376
+ ) ) ,
3377
+ Some ( & ProofAccount :: ContextAccount (
3378
+ range_proof_context_state_pubkey,
3379
+ ) ) ,
3360
3380
amount,
3361
3381
decimals,
3362
3382
Some ( withdraw_account_info) ,
@@ -3367,15 +3387,22 @@ async fn command_deposit_withdraw_confidential_tokens(
3367
3387
. await ?;
3368
3388
3369
3389
// 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,
3390
+ let _ = try_join ! (
3391
+ token. confidential_transfer_close_context_state(
3392
+ & equality_proof_context_state_pubkey,
3393
+ & token_account_address,
3394
+ & context_state_authority_pubkey,
3395
+ & context_state_authority,
3396
+ ) ,
3397
+ token. confidential_transfer_close_context_state(
3398
+ & range_proof_context_state_pubkey,
3374
3399
& token_account_address,
3375
3400
& context_state_authority_pubkey,
3376
3401
& context_state_authority,
3377
3402
)
3378
- . await ?
3403
+ ) ?;
3404
+
3405
+ withdraw_result
3379
3406
}
3380
3407
} ;
3381
3408
@@ -3447,8 +3474,8 @@ async fn command_apply_pending_balance(
3447
3474
struct ConfidentialTransferArgs {
3448
3475
sender_elgamal_keypair : ElGamalKeypair ,
3449
3476
sender_aes_key : AeKey ,
3450
- recipient_elgamal_pubkey : Option < ElGamalPubkey > ,
3451
- auditor_elgamal_pubkey : Option < ElGamalPubkey > ,
3477
+ recipient_elgamal_pubkey : Option < PodElGamalPubkey > ,
3478
+ auditor_elgamal_pubkey : Option < PodElGamalPubkey > ,
3452
3479
}
3453
3480
3454
3481
pub async fn process_command < ' a > (
0 commit comments