Skip to content

Commit

Permalink
[token-2022] Update to check_zk_elgamal_proof_program_account (#7163)
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto authored Aug 19, 2024
1 parent 2d0cb06 commit 342e227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions token/program-2022/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ pub fn check_spl_token_program_account(spl_token_program_id: &Pubkey) -> Program
Ok(())
}

/// Checks that the supplied program ID is correct for the ZK Token proof
/// Checks that the supplied program ID is correct for the ZK ElGamal proof
/// program
pub fn check_zk_token_proof_program_account(zk_token_proof_program_id: &Pubkey) -> ProgramResult {
if zk_token_proof_program_id != &solana_zk_sdk::zk_elgamal_proof_program::id() {
pub fn check_zk_elgamal_proof_program_account(
zk_elgamal_proof_program_id: &Pubkey,
) -> ProgramResult {
if zk_elgamal_proof_program_id != &solana_zk_sdk::zk_elgamal_proof_program::id() {
return Err(ProgramError::IncorrectProgramId);
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions token/program-2022/src/proof.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Helper for processing instruction data from ZK ElGamal proof program

use {
crate::check_zk_token_proof_program_account,
crate::check_zk_elgamal_proof_program_account,
bytemuck::Pod,
solana_program::{
account_info::{next_account_info, AccountInfo},
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn verify_and_extract_context<'a, T: Pod + ZkProofData<U>, U: Pod>(
if proof_instruction_offset == 0 {
// interpret `account_info` as a context state account
let context_state_account_info = next_account_info(account_info_iter)?;
check_zk_token_proof_program_account(context_state_account_info.owner)?;
check_zk_elgamal_proof_program_account(context_state_account_info.owner)?;
let context_state_account_data = context_state_account_info.data.borrow();
let context_state = pod_from_bytes::<ProofContextState<U>>(&context_state_account_data)?;

Expand Down

0 comments on commit 342e227

Please sign in to comment.