34
34
CiphertextCiphertextEqualityProofContext , CiphertextCiphertextEqualityProofData ,
35
35
} ,
36
36
} ,
37
+ spl_pod:: optional_keys:: OptionalNonZeroPubkey ,
37
38
spl_token_confidential_transfer_proof_extraction:: instruction:: verify_and_extract_context,
38
39
} ;
39
40
@@ -48,7 +49,6 @@ fn process_initialize_mint(accounts: &[AccountInfo], data: &InitializeMintData)
48
49
let mut mint = PodStateWithExtensionsMut :: < PodMint > :: unpack_uninitialized ( mint_data) ?;
49
50
let mint_burn_extension = mint. init_extension :: < ConfidentialMintBurn > ( true ) ?;
50
51
51
- mint_burn_extension. authority = data. authority ;
52
52
mint_burn_extension. supply_elgamal_pubkey = data. supply_elgamal_pubkey ;
53
53
mint_burn_extension. decryptable_supply = data. decryptable_supply ;
54
54
@@ -68,6 +68,7 @@ fn process_rotate_supply_elgamal_pubkey(
68
68
check_program_account ( mint_info. owner ) ?;
69
69
let mint_data = & mut mint_info. data . borrow_mut ( ) ;
70
70
let mut mint = PodStateWithExtensionsMut :: < PodMint > :: unpack ( mint_data) ?;
71
+ let mint_authority = mint. base . mint_authority ;
71
72
let mint_burn_extension = mint. get_extension_mut :: < ConfidentialMintBurn > ( ) ?;
72
73
73
74
let proof_context = verify_and_extract_context :: <
@@ -95,8 +96,8 @@ fn process_rotate_supply_elgamal_pubkey(
95
96
let authority_info = next_account_info ( account_info_iter) ?;
96
97
let authority_info_data_len = authority_info. data_len ( ) ;
97
98
98
- let authority = Option :: < Pubkey > :: from ( mint_burn_extension . authority )
99
- . ok_or ( TokenError :: NoAuthorityExists ) ?;
99
+ let authority = OptionalNonZeroPubkey :: try_from ( mint_authority ) ? ;
100
+ let authority = Option :: < Pubkey > :: from ( authority ) . ok_or ( TokenError :: NoAuthorityExists ) ?;
100
101
101
102
Processor :: validate_owner (
102
103
program_id,
@@ -126,10 +127,11 @@ fn process_update_decryptable_supply(
126
127
check_program_account ( mint_info. owner ) ?;
127
128
let mint_data = & mut mint_info. data . borrow_mut ( ) ;
128
129
let mut mint = PodStateWithExtensionsMut :: < PodMint > :: unpack ( mint_data) ?;
130
+ let mint_authority = mint. base . mint_authority ;
129
131
let mint_burn_extension = mint. get_extension_mut :: < ConfidentialMintBurn > ( ) ?;
130
132
131
- let authority = Option :: < Pubkey > :: from ( mint_burn_extension . authority )
132
- . ok_or ( TokenError :: NoAuthorityExists ) ?;
133
+ let authority = OptionalNonZeroPubkey :: try_from ( mint_authority ) ? ;
134
+ let authority = Option :: < Pubkey > :: from ( authority ) . ok_or ( TokenError :: NoAuthorityExists ) ?;
133
135
134
136
Processor :: validate_owner (
135
137
program_id,
@@ -158,6 +160,7 @@ fn process_confidential_mint(
158
160
check_program_account ( mint_info. owner ) ?;
159
161
let mint_data = & mut mint_info. data . borrow_mut ( ) ;
160
162
let mut mint = PodStateWithExtensionsMut :: < PodMint > :: unpack ( mint_data) ?;
163
+ let mint_authority = mint. base . mint_authority ;
161
164
162
165
let auditor_elgamal_pubkey = mint
163
166
. get_extension :: < ConfidentialTransferMint > ( ) ?
@@ -178,8 +181,8 @@ fn process_confidential_mint(
178
181
let authority_info = next_account_info ( account_info_iter) ?;
179
182
let authority_info_data_len = authority_info. data_len ( ) ;
180
183
181
- let authority = Option :: < Pubkey > :: from ( mint_burn_extension . authority )
182
- . ok_or ( TokenError :: NoAuthorityExists ) ?;
184
+ let authority = OptionalNonZeroPubkey :: try_from ( mint_authority ) ? ;
185
+ let authority = Option :: < Pubkey > :: from ( authority ) . ok_or ( TokenError :: NoAuthorityExists ) ?;
183
186
184
187
Processor :: validate_owner (
185
188
program_id,
@@ -314,19 +317,19 @@ fn process_confidential_burn(
314
317
return Err ( TokenError :: ConfidentialTransferElGamalPubkeyMismatch . into ( ) ) ;
315
318
}
316
319
317
- let source_transfer_amount_lo = & proof_context
320
+ let burn_amount_lo = & proof_context
318
321
. burn_amount_ciphertext_lo
319
322
. try_extract_ciphertext ( 0 )
320
323
. map_err ( |_| ProgramError :: InvalidAccountData ) ?;
321
- let source_transfer_amount_hi = & proof_context
324
+ let burn_amount_hi = & proof_context
322
325
. burn_amount_ciphertext_hi
323
326
. try_extract_ciphertext ( 0 )
324
327
. map_err ( |_| ProgramError :: InvalidAccountData ) ?;
325
328
326
329
let new_source_available_balance = ciphertext_arithmetic:: subtract_with_lo_hi (
327
330
& confidential_transfer_account. available_balance ,
328
- source_transfer_amount_lo ,
329
- source_transfer_amount_hi ,
331
+ burn_amount_lo ,
332
+ burn_amount_hi ,
330
333
)
331
334
. ok_or ( TokenError :: CiphertextArithmeticFailed ) ?;
332
335
0 commit comments