Skip to content

Commit

Permalink
Use Signers in transfer_with_split_proofs_in_parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Oct 26, 2023
1 parent eb7ef58 commit 1959b73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
25 changes: 5 additions & 20 deletions token/client/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,7 @@ where
/// This function internally generates the ZK Token proof instructions to create the necessary
/// proof context states.
#[allow(clippy::too_many_arguments)]
pub async fn confidential_transfer_transfer_with_split_proofs_in_parallel<S: Signer>(
pub async fn confidential_transfer_transfer_with_split_proofs_in_parallel<S: Signers>(
&self,
source_account: &Pubkey,
destination_account: &Pubkey,
Expand All @@ -2317,11 +2317,8 @@ where
source_aes_key: &AeKey,
destination_elgamal_pubkey: &ElGamalPubkey,
auditor_elgamal_pubkey: Option<&ElGamalPubkey>,
source_authority_keypair: &S,
equality_proof_account_keypair: &S,
ciphertext_validity_proof_account_keypair: &S,
range_proof_account_keypair: &S,
context_state_authority_keypair: Option<&S>,
equality_and_ciphertext_validity_proof_signers: &S,
range_proof_signers: &S,
) -> TokenResult<(T::Output, T::Output)> {
let account_info = if let Some(account_info) = account_info {
account_info
Expand Down Expand Up @@ -2362,33 +2359,21 @@ where
&source_decrypt_handles,
)?;

let mut equality_and_ciphertext_signers = vec![
&source_authority_keypair,
&equality_proof_account_keypair,
&ciphertext_validity_proof_account_keypair,
];
if let Some(context_state_authority_keypair) = &context_state_authority_keypair {
equality_and_ciphertext_signers.push(context_state_authority_keypair);
}
let transfer_with_equality_and_ciphertext_validity = self
.create_equality_and_ciphertext_validity_proof_context_states_for_transfer_parallel(
context_state_accounts,
&equality_proof_data,
&ciphertext_validity_proof_data,
&transfer_instruction,
&equality_and_ciphertext_signers,
equality_and_ciphertext_validity_proof_signers,
);

let mut range_proof_signers = vec![source_authority_keypair, range_proof_account_keypair];
if let Some(context_state_authority_keypair) = &context_state_authority_keypair {
range_proof_signers.push(context_state_authority_keypair);
}
let transfer_with_range_proof = self
.create_range_proof_context_state_for_transfer_parallel(
context_state_accounts,
&range_proof_data,
&transfer_instruction,
&range_proof_signers,
range_proof_signers,
);

try_join!(
Expand Down
13 changes: 8 additions & 5 deletions token/program-2022-test/tests/confidential_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,12 @@ async fn confidential_transfer_transfer_with_split_proof_contexts_in_parallel()
close_split_context_state_accounts: None,
};

let equality_signers = vec![
&alice,
&equality_proof_context_state_account,
&ciphertext_validity_proof_context_state_account,
];
let range_proof_signers = vec![&alice, &range_proof_context_state_account];
token
.confidential_transfer_transfer_with_split_proofs_in_parallel(
&alice_meta.token_account,
Expand All @@ -2628,11 +2634,8 @@ async fn confidential_transfer_transfer_with_split_proof_contexts_in_parallel()
&alice_meta.aes_key,
bob_meta.elgamal_keypair.pubkey(),
Some(auditor_elgamal_keypair.pubkey()),
&alice,
&equality_proof_context_state_account,
&ciphertext_validity_proof_context_state_account,
&range_proof_context_state_account,
None,
&equality_signers,
&range_proof_signers,
)
.await
.unwrap();
Expand Down

0 comments on commit 1959b73

Please sign in to comment.