1- #![ cfg( feature = "test-sbf" ) ]
1+ // #![cfg(feature = "test-sbf")]
22
33mod program_test;
44use {
1919 } ,
2020 spl_token_client:: {
2121 client:: ProgramBanksClientProcessTransaction ,
22- token:: { ExtensionInitializationParams , ProofAccount , Token } ,
22+ token:: { ExtensionInitializationParams , ProofAccount , ProofAccountWithCiphertext , Token } ,
2323 } ,
2424 spl_token_confidential_transfer_proof_generation:: {
2525 burn:: burn_split_proof_data, mint:: mint_split_proof_data,
@@ -36,21 +36,27 @@ async fn test_confidential_mint() {
3636 let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
3737 let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
3838 let supply_aes_key = AeKey :: new_rand ( ) ;
39+ let mint_account = Keypair :: new ( ) ;
3940
4041 let mut context = TestContext :: new ( ) . await ;
4142 context
42- . init_token_with_mint ( vec ! [
43- ExtensionInitializationParams :: ConfidentialTransferMint {
44- authority: Some ( authority. pubkey( ) ) ,
45- auto_approve_new_accounts: true ,
46- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
47- } ,
48- ExtensionInitializationParams :: ConfidentialMintBurnMint {
49- authority: authority. pubkey( ) ,
50- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
51- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
52- } ,
53- ] )
43+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
44+ mint_account,
45+ vec ! [
46+ ExtensionInitializationParams :: ConfidentialTransferMint {
47+ authority: Some ( authority. pubkey( ) ) ,
48+ auto_approve_new_accounts: true ,
49+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
50+ } ,
51+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
52+ confidential_supply_pubkey: auditor_elgamal_pubkey,
53+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
54+ } ,
55+ ] ,
56+ None ,
57+ // hacky but we have to clone somehow
58+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
59+ )
5460 . await
5561 . unwrap ( ) ;
5662
@@ -121,21 +127,26 @@ async fn test_confidential_burn() {
121127 let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
122128 let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
123129 let supply_aes_key = AeKey :: new_rand ( ) ;
130+ let mint_account = Keypair :: new ( ) ;
124131
125132 let mut context = TestContext :: new ( ) . await ;
126133 context
127- . init_token_with_mint ( vec ! [
128- ExtensionInitializationParams :: ConfidentialTransferMint {
129- authority: Some ( authority. pubkey( ) ) ,
130- auto_approve_new_accounts: true ,
131- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
132- } ,
133- ExtensionInitializationParams :: ConfidentialMintBurnMint {
134- authority: authority. pubkey( ) ,
135- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
136- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
137- } ,
138- ] )
134+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
135+ mint_account,
136+ vec ! [
137+ ExtensionInitializationParams :: ConfidentialTransferMint {
138+ authority: Some ( authority. pubkey( ) ) ,
139+ auto_approve_new_accounts: true ,
140+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
141+ } ,
142+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
143+ confidential_supply_pubkey: auditor_elgamal_pubkey,
144+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
145+ } ,
146+ ] ,
147+ None ,
148+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
149+ )
139150 . await
140151 . unwrap ( ) ;
141152
@@ -227,7 +238,9 @@ async fn test_confidential_burn() {
227238 . confidential_transfer_create_context_state_account (
228239 & ciphertext_validity_proof_context_pubkey,
229240 & context_state_auth_pubkey,
230- & proof_data. ciphertext_validity_proof_data ,
241+ & proof_data
242+ . ciphertext_validity_proof_data_with_ciphertext
243+ . proof_data ,
231244 false ,
232245 ciphertext_validity_proof_signer,
233246 )
@@ -247,6 +260,15 @@ async fn test_confidential_burn() {
247260 let equality_proof_location = ProofAccount :: ContextAccount ( equality_proof_context_pubkey) ;
248261 let ciphertext_validity_proof_location =
249262 ProofAccount :: ContextAccount ( ciphertext_validity_proof_context_pubkey) ;
263+ let ciphertext_validity_proof_location = ProofAccountWithCiphertext {
264+ proof_account : ciphertext_validity_proof_location,
265+ ciphertext_lo : proof_data
266+ . ciphertext_validity_proof_data_with_ciphertext
267+ . ciphertext_lo ,
268+ ciphertext_hi : proof_data
269+ . ciphertext_validity_proof_data_with_ciphertext
270+ . ciphertext_hi ,
271+ } ;
250272 let range_proof_location = ProofAccount :: ContextAccount ( range_proof_context_pubkey) ;
251273
252274 // do the burn
@@ -324,21 +346,26 @@ async fn test_rotate_supply_elgamal() {
324346 let auditor_elgamal_keypair = ElGamalKeypair :: new_rand ( ) ;
325347 let auditor_elgamal_pubkey = ( * auditor_elgamal_keypair. pubkey ( ) ) . into ( ) ;
326348 let supply_aes_key = AeKey :: new_rand ( ) ;
349+ let mint_account = Keypair :: new ( ) ;
327350
328351 let mut context = TestContext :: new ( ) . await ;
329352 context
330- . init_token_with_mint ( vec ! [
331- ExtensionInitializationParams :: ConfidentialTransferMint {
332- authority: Some ( authority. pubkey( ) ) ,
333- auto_approve_new_accounts: true ,
334- auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
335- } ,
336- ExtensionInitializationParams :: ConfidentialMintBurnMint {
337- authority: authority. pubkey( ) ,
338- confidential_supply_pubkey: Some ( auditor_elgamal_pubkey) ,
339- decryptable_supply: Some ( supply_aes_key. encrypt( 0 ) . into( ) ) ,
340- } ,
341- ] )
353+ . init_token_with_mint_keypair_and_freeze_authority_and_mint_authority (
354+ mint_account,
355+ vec ! [
356+ ExtensionInitializationParams :: ConfidentialTransferMint {
357+ authority: Some ( authority. pubkey( ) ) ,
358+ auto_approve_new_accounts: true ,
359+ auditor_elgamal_pubkey: Some ( auditor_elgamal_pubkey) ,
360+ } ,
361+ ExtensionInitializationParams :: ConfidentialMintBurnMint {
362+ confidential_supply_pubkey: auditor_elgamal_pubkey,
363+ decryptable_supply: supply_aes_key. encrypt( 0 ) . into( ) ,
364+ } ,
365+ ] ,
366+ None ,
367+ Keypair :: from_bytes ( & authority. to_bytes ( ) ) . unwrap ( ) ,
368+ )
342369 . await
343370 . unwrap ( ) ;
344371
@@ -400,11 +427,7 @@ async fn test_rotate_supply_elgamal() {
400427
401428 assert_eq ! (
402429 mint_burn_extension. supply_elgamal_pubkey,
403- Some ( Into :: <PodElGamalPubkey >:: into(
404- * new_supply_elgamal_keypair. pubkey( ) ,
405- ) )
406- . try_into( )
407- . unwrap( ) ,
430+ Into :: <PodElGamalPubkey >:: into( * new_supply_elgamal_keypair. pubkey( ) , ) ,
408431 ) ;
409432}
410433
@@ -465,7 +488,9 @@ async fn mint_tokens(
465488 . confidential_transfer_create_context_state_account (
466489 & ciphertext_validity_proof_context_pubkey,
467490 & context_state_auth. pubkey ( ) ,
468- & proof_data. ciphertext_validity_proof_data ,
491+ & proof_data
492+ . ciphertext_validity_proof_data_with_ciphertext
493+ . proof_data ,
469494 false ,
470495 ciphertext_validity_proof_signer,
471496 )
@@ -485,8 +510,21 @@ async fn mint_tokens(
485510 let equality_proof_location = ProofAccount :: ContextAccount ( equality_proof_context_pubkey) ;
486511 let ciphertext_validity_proof_location =
487512 ProofAccount :: ContextAccount ( ciphertext_validity_proof_context_pubkey) ;
513+ let ciphertext_validity_proof_location = ProofAccountWithCiphertext {
514+ proof_account : ciphertext_validity_proof_location,
515+ ciphertext_lo : proof_data
516+ . ciphertext_validity_proof_data_with_ciphertext
517+ . ciphertext_lo ,
518+ ciphertext_hi : proof_data
519+ . ciphertext_validity_proof_data_with_ciphertext
520+ . ciphertext_hi ,
521+ } ;
488522 let range_proof_location = ProofAccount :: ContextAccount ( range_proof_context_pubkey) ;
489523
524+ println ! (
525+ "TOKEN: {}, ata: {token_account}, auth: {authority}" ,
526+ token. get_address( )
527+ ) ;
490528 token
491529 . confidential_mint (
492530 token_account,
0 commit comments