Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 5256e9d

Browse files
committed
more fixes
1 parent f601fdd commit 5256e9d

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

token/program-2022/src/extension/confidential_mint_burn/instruction.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use {
1717
pubkey::Pubkey,
1818
},
1919
solana_zk_sdk::encryption::pod::{auth_encryption::PodAeCiphertext, elgamal::PodElGamalPubkey},
20-
spl_pod::optional_keys::OptionalNonZeroPubkey,
2120
};
2221
#[cfg(not(target_os = "solana"))]
2322
use {
@@ -187,9 +186,6 @@ pub enum ConfidentialMintBurnInstruction {
187186
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
188187
#[repr(C)]
189188
pub struct InitializeMintData {
190-
/// Authority used to modify the `ConfidentialMintBurn` mint
191-
/// configuration and mint new tokens
192-
pub authority: OptionalNonZeroPubkey,
193189
/// The ElGamal pubkey used to encrypt the confidential supply
194190
#[cfg_attr(feature = "serde-traits", serde(with = "elgamalpubkey_fromstr"))]
195191
pub supply_elgamal_pubkey: PodElGamalPubkey,
@@ -278,21 +274,18 @@ pub struct BurnInstructionData {
278274
pub fn initialize_mint(
279275
token_program_id: &Pubkey,
280276
mint: &Pubkey,
281-
authority: &Pubkey,
282277
supply_elgamal_pubkey: PodElGamalPubkey,
283278
decryptable_supply: PodAeCiphertext,
284279
) -> Result<Instruction, ProgramError> {
285280
check_program_account(token_program_id)?;
286281
let accounts = vec![AccountMeta::new(*mint, false)];
287282

288-
let authority = Some(*authority);
289283
Ok(encode_instruction(
290284
token_program_id,
291285
accounts,
292286
TokenInstruction::ConfidentialMintBurnExtension,
293287
ConfidentialMintBurnInstruction::InitializeMint,
294288
&InitializeMintData {
295-
authority: authority.try_into()?,
296289
supply_elgamal_pubkey,
297290
decryptable_supply,
298291
},

token/program-2022/src/extension/confidential_mint_burn/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
auth_encryption::PodAeCiphertext,
66
elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
77
},
8-
spl_pod::optional_keys::OptionalNonZeroPubkey,
98
};
109

1110
/// Maximum bit length of any mint or burn amount
@@ -33,9 +32,6 @@ pub mod account_info;
3332
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
3433
#[repr(C)]
3534
pub struct ConfidentialMintBurn {
36-
/// Authority to modify the `ConfidentialMintBurnMint` configuration and to
37-
/// mint new confidential tokens
38-
pub authority: OptionalNonZeroPubkey,
3935
/// The confidential supply of the mint (encrypted by `encryption_pubkey`)
4036
pub confidential_supply: PodElGamalCiphertext,
4137
/// The decryptable confidential supply of the mint

token/program-2022/src/extension/confidential_mint_burn/processor.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use {
3434
CiphertextCiphertextEqualityProofContext, CiphertextCiphertextEqualityProofData,
3535
},
3636
},
37+
spl_pod::optional_keys::OptionalNonZeroPubkey,
3738
spl_token_confidential_transfer_proof_extraction::instruction::verify_and_extract_context,
3839
};
3940

@@ -48,7 +49,6 @@ fn process_initialize_mint(accounts: &[AccountInfo], data: &InitializeMintData)
4849
let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack_uninitialized(mint_data)?;
4950
let mint_burn_extension = mint.init_extension::<ConfidentialMintBurn>(true)?;
5051

51-
mint_burn_extension.authority = data.authority;
5252
mint_burn_extension.supply_elgamal_pubkey = data.supply_elgamal_pubkey;
5353
mint_burn_extension.decryptable_supply = data.decryptable_supply;
5454

@@ -68,6 +68,7 @@ fn process_rotate_supply_elgamal_pubkey(
6868
check_program_account(mint_info.owner)?;
6969
let mint_data = &mut mint_info.data.borrow_mut();
7070
let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack(mint_data)?;
71+
let mint_authority = mint.base.mint_authority;
7172
let mint_burn_extension = mint.get_extension_mut::<ConfidentialMintBurn>()?;
7273

7374
let proof_context = verify_and_extract_context::<
@@ -95,8 +96,8 @@ fn process_rotate_supply_elgamal_pubkey(
9596
let authority_info = next_account_info(account_info_iter)?;
9697
let authority_info_data_len = authority_info.data_len();
9798

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)?;
100101

101102
Processor::validate_owner(
102103
program_id,
@@ -126,10 +127,11 @@ fn process_update_decryptable_supply(
126127
check_program_account(mint_info.owner)?;
127128
let mint_data = &mut mint_info.data.borrow_mut();
128129
let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack(mint_data)?;
130+
let mint_authority = mint.base.mint_authority;
129131
let mint_burn_extension = mint.get_extension_mut::<ConfidentialMintBurn>()?;
130132

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)?;
133135

134136
Processor::validate_owner(
135137
program_id,
@@ -158,6 +160,7 @@ fn process_confidential_mint(
158160
check_program_account(mint_info.owner)?;
159161
let mint_data = &mut mint_info.data.borrow_mut();
160162
let mut mint = PodStateWithExtensionsMut::<PodMint>::unpack(mint_data)?;
163+
let mint_authority = mint.base.mint_authority;
161164

162165
let auditor_elgamal_pubkey = mint
163166
.get_extension::<ConfidentialTransferMint>()?
@@ -178,8 +181,8 @@ fn process_confidential_mint(
178181
let authority_info = next_account_info(account_info_iter)?;
179182
let authority_info_data_len = authority_info.data_len();
180183

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)?;
183186

184187
Processor::validate_owner(
185188
program_id,
@@ -314,19 +317,19 @@ fn process_confidential_burn(
314317
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
315318
}
316319

317-
let source_transfer_amount_lo = &proof_context
320+
let burn_amount_lo = &proof_context
318321
.burn_amount_ciphertext_lo
319322
.try_extract_ciphertext(0)
320323
.map_err(|_| ProgramError::InvalidAccountData)?;
321-
let source_transfer_amount_hi = &proof_context
324+
let burn_amount_hi = &proof_context
322325
.burn_amount_ciphertext_hi
323326
.try_extract_ciphertext(0)
324327
.map_err(|_| ProgramError::InvalidAccountData)?;
325328

326329
let new_source_available_balance = ciphertext_arithmetic::subtract_with_lo_hi(
327330
&confidential_transfer_account.available_balance,
328-
source_transfer_amount_lo,
329-
source_transfer_amount_hi,
331+
burn_amount_lo,
332+
burn_amount_hi,
330333
)
331334
.ok_or(TokenError::CiphertextArithmeticFailed)?;
332335

token/program-2022/src/processor.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -905,20 +905,6 @@ impl Processor {
905905
)?;
906906
extension.authority = new_authority.try_into()?;
907907
}
908-
AuthorityType::MintConfidentialTokens => {
909-
let extension = mint.get_extension_mut::<ConfidentialMintBurn>()?;
910-
let maybe_authority: Option<Pubkey> = extension.authority.into();
911-
let authority = maybe_authority.ok_or(TokenError::AuthorityTypeNotSupported)?;
912-
913-
Self::validate_owner(
914-
program_id,
915-
&authority,
916-
authority_info,
917-
authority_info_data_len,
918-
account_info_iter.as_slice(),
919-
)?;
920-
extension.authority = new_authority.try_into()?;
921-
}
922908
_ => {
923909
return Err(TokenError::AuthorityTypeNotSupported.into());
924910
}

0 commit comments

Comments
 (0)