Skip to content

Commit

Permalink
make append_zk_elgamal_proof function more general
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto committed Oct 21, 2024
1 parent 01e54df commit 71d5e3b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions token/confidential-transfer/elgamal-registry/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ pub fn create_registry(
];
let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location);

let registry_instruction = Instruction {
let mut instructions = vec![Instruction {
program_id: id(),
accounts,
data: RegistryInstruction::CreateRegistry {
proof_instruction_offset,
}
.pack(),
};
append_zk_elgamal_proof(registry_instruction, proof_location)
}];
append_zk_elgamal_proof(&mut instructions, proof_location)?;
Ok(instructions)
}

/// Create a `RegistryInstruction::UpdateRegistry` instruction
Expand All @@ -137,15 +138,16 @@ pub fn update_registry(
let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location);
accounts.push(AccountMeta::new_readonly(*owner_address, true));

let registry_instruction = Instruction {
let mut instructions = vec![Instruction {
program_id: id(),
accounts,
data: RegistryInstruction::UpdateRegistry {
proof_instruction_offset,
}
.pack(),
};
append_zk_elgamal_proof(registry_instruction, proof_location)
}];
append_zk_elgamal_proof(&mut instructions, proof_location)?;
Ok(instructions)
}

/// Takes a `ProofLocation`, updates the list of accounts, and returns a
Expand All @@ -172,11 +174,9 @@ fn proof_instruction_offset(
/// Takes a `RegistryInstruction` and appends the pubkey validity proof
/// instruction
fn append_zk_elgamal_proof(
registry_instruction: Instruction,
instructions: &mut Vec<Instruction>,
proof_data_location: ProofLocation<PubkeyValidityProofData>,
) -> Result<Vec<Instruction>, ProgramError> {
let mut instructions = vec![registry_instruction];

) -> Result<(), ProgramError> {
if let ProofLocation::InstructionOffset(proof_instruction_offset, proof_data) =
proof_data_location
{
Expand All @@ -193,5 +193,5 @@ fn append_zk_elgamal_proof(
),
}
}
Ok(instructions)
Ok(())
}

0 comments on commit 71d5e3b

Please sign in to comment.