11#[ cfg( not( target_os = "solana" ) ) ]
2- use crate :: proof:: { process_proof_location, ProofLocation } ;
3- #[ cfg( not( target_os = "solana" ) ) ]
4- use solana_zk_sdk:: encryption:: { auth_encryption:: AeCiphertext , elgamal:: ElGamalPubkey } ;
5- #[ cfg( not( target_os = "solana" ) ) ]
6- use solana_zk_sdk:: zk_elgamal_proof_program:: {
7- instruction:: ProofInstruction ,
8- proof_data:: {
9- BatchedGroupedCiphertext3HandlesValidityProofData , BatchedRangeProofU128Data ,
10- CiphertextCiphertextEqualityProofData , CiphertextCommitmentEqualityProofData ,
2+ use {
3+ crate :: proof:: { process_proof_location, ProofLocation } ,
4+ solana_zk_sdk:: {
5+ encryption:: { auth_encryption:: AeCiphertext , elgamal:: ElGamalPubkey } ,
6+ zk_elgamal_proof_program:: {
7+ instruction:: ProofInstruction ,
8+ proof_data:: {
9+ BatchedGroupedCiphertext3HandlesValidityProofData , BatchedRangeProofU128Data ,
10+ CiphertextCiphertextEqualityProofData , CiphertextCommitmentEqualityProofData ,
11+ } ,
12+ } ,
1113 } ,
1214} ;
1315#[ cfg( feature = "serde-traits" ) ]
1416use {
15- crate :: serialization:: aeciphertext_fromstr,
17+ crate :: serialization:: { aeciphertext_fromstr, elgamalpubkey_fromstr } ,
1618 serde:: { Deserialize , Serialize } ,
1719} ;
1820use {
2931 pubkey:: Pubkey ,
3032 } ,
3133 solana_zk_sdk:: encryption:: pod:: { auth_encryption:: PodAeCiphertext , elgamal:: PodElGamalPubkey } ,
32- spl_pod:: optional_keys:: { OptionalNonZeroElGamalPubkey , OptionalNonZeroPubkey } ,
34+ spl_pod:: optional_keys:: OptionalNonZeroPubkey ,
3335} ;
3436
3537/// Confidential Transfer extension instructions
@@ -98,7 +100,6 @@ pub enum ConfidentialMintBurnInstruction {
98100 /// Mints tokens to confidential balance
99101 ///
100102 /// Fails if the destination account is frozen.
101- /// Fails if the associated mint is extended as `NonTransferable`.
102103 ///
103104 /// Accounts expected by this instruction:
104105 ///
@@ -135,11 +136,10 @@ pub enum ConfidentialMintBurnInstruction {
135136 ///
136137 /// Data expected by this instruction:
137138 /// `MintInstructionData`
138- ConfidentialMint ,
139+ Mint ,
139140 /// Burn tokens from confidential balance
140141 ///
141142 /// Fails if the destination account is frozen.
142- /// Fails if the associated mint is extended as `NonTransferable`.
143143 ///
144144 /// Accounts expected by this instruction:
145145 ///
@@ -176,7 +176,7 @@ pub enum ConfidentialMintBurnInstruction {
176176 ///
177177 /// Data expected by this instruction:
178178 /// `BurnInstructionData`
179- ConfidentialBurn ,
179+ Burn ,
180180}
181181
182182/// Data expected by `ConfidentialMintBurnInstruction::InitializeMint`
@@ -189,7 +189,8 @@ pub struct InitializeMintData {
189189 /// configuration and mint new tokens
190190 pub authority : OptionalNonZeroPubkey ,
191191 /// The ElGamal pubkey used to encrypt the confidential supply
192- pub supply_elgamal_pubkey : OptionalNonZeroElGamalPubkey ,
192+ #[ cfg_attr( feature = "serde-traits" , serde( with = "elgamalpubkey_fromstr" ) ) ]
193+ pub supply_elgamal_pubkey : PodElGamalPubkey ,
193194 /// The initial 0 supply ecrypted with the supply aes key
194195 #[ cfg_attr( feature = "serde-traits" , serde( with = "aeciphertext_fromstr" ) ) ]
195196 pub decryptable_supply : PodAeCiphertext ,
@@ -202,7 +203,8 @@ pub struct InitializeMintData {
202203#[ repr( C ) ]
203204pub struct RotateSupplyElGamalPubkeyData {
204205 /// The new ElGamal pubkey for supply encryption
205- pub new_supply_elgamal_pubkey : OptionalNonZeroElGamalPubkey ,
206+ #[ cfg_attr( feature = "serde-traits" , serde( with = "elgamalpubkey_fromstr" ) ) ]
207+ pub new_supply_elgamal_pubkey : PodElGamalPubkey ,
206208 /// The location of the
207209 /// `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction
208210 /// relative to the `RotateSupplyElGamal` instruction in the transaction
@@ -275,27 +277,21 @@ pub fn initialize_mint(
275277 token_program_id : & Pubkey ,
276278 mint : & Pubkey ,
277279 authority : & Pubkey ,
278- confidential_supply_pubkey : Option < PodElGamalPubkey > ,
279- decryptable_supply : Option < PodAeCiphertext > ,
280+ supply_elgamal_pubkey : PodElGamalPubkey ,
281+ decryptable_supply : PodAeCiphertext ,
280282) -> Result < Instruction , ProgramError > {
281283 check_program_account ( token_program_id) ?;
282284 let accounts = vec ! [ AccountMeta :: new( * mint, false ) ] ;
283285
284- let decryptable_supply = if confidential_supply_pubkey. is_some ( ) {
285- decryptable_supply. ok_or ( ProgramError :: InvalidInstructionData ) ?
286- } else {
287- PodAeCiphertext :: zeroed ( )
288- } ;
289-
290- let authority = Some ( authority) ;
286+ let authority = Some ( * authority) ;
291287 Ok ( encode_instruction (
292288 token_program_id,
293289 accounts,
294290 TokenInstruction :: ConfidentialMintBurnExtension ,
295291 ConfidentialMintBurnInstruction :: InitializeMint ,
296292 & InitializeMintData {
297293 authority : authority. try_into ( ) ?,
298- supply_elgamal_pubkey : confidential_supply_pubkey . try_into ( ) ? ,
294+ supply_elgamal_pubkey,
299295 decryptable_supply,
300296 } ,
301297 ) )
@@ -341,10 +337,7 @@ pub fn rotate_supply_elgamal_pubkey(
341337 TokenInstruction :: ConfidentialMintBurnExtension ,
342338 ConfidentialMintBurnInstruction :: RotateSupplyElGamalPubkey ,
343339 & RotateSupplyElGamalPubkeyData {
344- new_supply_elgamal_pubkey: Some ( Into :: <PodElGamalPubkey >:: into(
345- new_supply_elgamal_pubkey,
346- ) )
347- . try_into( ) ?,
340+ new_supply_elgamal_pubkey: PodElGamalPubkey :: from( new_supply_elgamal_pubkey) ,
348341 proof_instruction_offset,
349342 } ,
350343 ) ] ;
@@ -464,7 +457,7 @@ pub fn confidential_mint_with_split_proofs(
464457 token_program_id,
465458 accounts,
466459 TokenInstruction :: ConfidentialMintBurnExtension ,
467- ConfidentialMintBurnInstruction :: ConfidentialMint ,
460+ ConfidentialMintBurnInstruction :: Mint ,
468461 & MintInstructionData {
469462 new_decryptable_supply: new_decryptable_supply. into( ) ,
470463 equality_proof_instruction_offset,
@@ -546,7 +539,7 @@ pub fn confidential_burn_with_split_proofs(
546539 token_program_id,
547540 accounts,
548541 TokenInstruction :: ConfidentialMintBurnExtension ,
549- ConfidentialMintBurnInstruction :: ConfidentialBurn ,
542+ ConfidentialMintBurnInstruction :: Burn ,
550543 & BurnInstructionData {
551544 new_decryptable_available_balance,
552545 equality_proof_instruction_offset,
0 commit comments