remove ElGamal pubkey from confidential transfer `ConfigureAccount` data (#3927)

This commit is contained in:
samkim-crypto 2022-12-19 11:58:46 +09:00 committed by GitHub
parent 9a0ecb3814
commit ba2b7951fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 15 deletions

View File

@ -1558,7 +1558,6 @@ where
&self.program_id, &self.program_id,
token_account, token_account,
&self.pubkey, &self.pubkey,
elgamal_keypair.public.into(),
decryptable_zero_balance, decryptable_zero_balance,
maximum_pending_balance_credit_counter, maximum_pending_balance_credit_counter,
&authority.pubkey(), &authority.pubkey(),

View File

@ -423,8 +423,6 @@ pub enum ConfidentialTransferInstruction {
#[derive(Clone, Copy, Pod, Zeroable)] #[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
pub struct ConfigureAccountInstructionData { pub struct ConfigureAccountInstructionData {
/// The public key associated with the account
pub encryption_pubkey: EncryptionPubkey,
/// The decryptable balance (always 0) once the configure account succeeds /// The decryptable balance (always 0) once the configure account succeeds
pub decryptable_zero_balance: DecryptableBalance, pub decryptable_zero_balance: DecryptableBalance,
/// The maximum number of despots and transfers that an account can receiver before the /// The maximum number of despots and transfers that an account can receiver before the
@ -562,7 +560,6 @@ pub fn inner_configure_account(
token_program_id: &Pubkey, token_program_id: &Pubkey,
token_account: &Pubkey, token_account: &Pubkey,
mint: &Pubkey, mint: &Pubkey,
encryption_pubkey: EncryptionPubkey,
decryptable_zero_balance: AeCiphertext, decryptable_zero_balance: AeCiphertext,
maximum_pending_balance_credit_counter: u64, maximum_pending_balance_credit_counter: u64,
authority: &Pubkey, authority: &Pubkey,
@ -587,7 +584,6 @@ pub fn inner_configure_account(
TokenInstruction::ConfidentialTransferExtension, TokenInstruction::ConfidentialTransferExtension,
ConfidentialTransferInstruction::ConfigureAccount, ConfidentialTransferInstruction::ConfigureAccount,
&ConfigureAccountInstructionData { &ConfigureAccountInstructionData {
encryption_pubkey,
decryptable_zero_balance: decryptable_zero_balance.into(), decryptable_zero_balance: decryptable_zero_balance.into(),
maximum_pending_balance_credit_counter: maximum_pending_balance_credit_counter.into(), maximum_pending_balance_credit_counter: maximum_pending_balance_credit_counter.into(),
proof_instruction_offset, proof_instruction_offset,
@ -602,7 +598,6 @@ pub fn configure_account(
token_program_id: &Pubkey, token_program_id: &Pubkey,
token_account: &Pubkey, token_account: &Pubkey,
mint: &Pubkey, mint: &Pubkey,
encryption_pubkey: EncryptionPubkey,
decryptable_zero_balance: AeCiphertext, decryptable_zero_balance: AeCiphertext,
maximum_pending_balance_credit_counter: u64, maximum_pending_balance_credit_counter: u64,
authority: &Pubkey, authority: &Pubkey,
@ -614,7 +609,6 @@ pub fn configure_account(
token_program_id, token_program_id,
token_account, token_account,
mint, mint,
encryption_pubkey,
decryptable_zero_balance, decryptable_zero_balance,
maximum_pending_balance_credit_counter, maximum_pending_balance_credit_counter,
authority, authority,

View File

@ -99,7 +99,6 @@ fn process_update_mint(
fn process_configure_account( fn process_configure_account(
program_id: &Pubkey, program_id: &Pubkey,
accounts: &[AccountInfo], accounts: &[AccountInfo],
encryption_pubkey: &EncryptionPubkey,
decryptable_zero_balance: &DecryptableBalance, decryptable_zero_balance: &DecryptableBalance,
maximum_pending_balance_credit_counter: &PodU64, maximum_pending_balance_credit_counter: &PodU64,
proof_instruction_offset: i64, proof_instruction_offset: i64,
@ -139,18 +138,13 @@ fn process_configure_account(
ProofInstruction::VerifyPubkeyValidity, ProofInstruction::VerifyPubkeyValidity,
&zkp_instruction, &zkp_instruction,
)?; )?;
// Check that the encryption public key associated with the confidential extension account is
// consistent with what was actually used to generate the zkp.
if proof_data.pubkey != *encryption_pubkey {
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
}
// Note: The caller is expected to use the `Reallocate` instruction to ensure there is // Note: The caller is expected to use the `Reallocate` instruction to ensure there is
// sufficient room in their token account for the new `ConfidentialTransferAccount` extension // sufficient room in their token account for the new `ConfidentialTransferAccount` extension
let mut confidential_transfer_account = let mut confidential_transfer_account =
token_account.init_extension::<ConfidentialTransferAccount>(false)?; token_account.init_extension::<ConfidentialTransferAccount>(false)?;
confidential_transfer_account.approved = confidential_transfer_mint.auto_approve_new_accounts; confidential_transfer_account.approved = confidential_transfer_mint.auto_approve_new_accounts;
confidential_transfer_account.encryption_pubkey = *encryption_pubkey; confidential_transfer_account.encryption_pubkey = proof_data.pubkey;
confidential_transfer_account.maximum_pending_balance_credit_counter = confidential_transfer_account.maximum_pending_balance_credit_counter =
*maximum_pending_balance_credit_counter; *maximum_pending_balance_credit_counter;
@ -1204,7 +1198,6 @@ pub(crate) fn process_instruction(
process_configure_account( process_configure_account(
program_id, program_id,
accounts, accounts,
&data.encryption_pubkey,
&data.decryptable_zero_balance, &data.decryptable_zero_balance,
&data.maximum_pending_balance_credit_counter, &data.maximum_pending_balance_credit_counter,
data.proof_instruction_offset as i64, data.proof_instruction_offset as i64,