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

Commit c7fbd4b

Browse files
check expected new source ciphertext in processing confidential transfer (#3867)
1 parent 6a8cf4f commit c7fbd4b

File tree

1 file changed

+7
-0
lines changed
  • token/program-2022/src/extension/confidential_transfer

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ fn process_transfer(
585585
&proof_data.transfer_with_fee_pubkeys.source_pubkey,
586586
&source_ciphertext_lo,
587587
&source_ciphertext_hi,
588+
&proof_data.new_source_ciphertext,
588589
new_source_decryptable_available_balance,
589590
)?;
590591

@@ -643,6 +644,7 @@ fn process_transfer(
643644
&proof_data.transfer_pubkeys.source_pubkey,
644645
&source_ciphertext_lo,
645646
&source_ciphertext_hi,
647+
&proof_data.new_source_ciphertext,
646648
new_source_decryptable_available_balance,
647649
)?;
648650

@@ -679,6 +681,7 @@ fn process_source_for_transfer(
679681
source_encryption_pubkey: &EncryptionPubkey,
680682
source_ciphertext_lo: &EncryptedBalance,
681683
source_ciphertext_hi: &EncryptedBalance,
684+
expected_new_source_available_balance: &EncryptedBalance,
682685
new_source_decryptable_available_balance: DecryptableBalance,
683686
) -> ProgramResult {
684687
check_program_account(token_account_info.owner)?;
@@ -719,6 +722,10 @@ fn process_source_for_transfer(
719722
.ok_or(ProgramError::InvalidInstructionData)?
720723
};
721724

725+
if new_source_available_balance != *expected_new_source_available_balance {
726+
return Err(TokenError::ConfidentialTransferBalanceMismatch.into());
727+
}
728+
722729
confidential_transfer_account.available_balance = new_source_available_balance;
723730
confidential_transfer_account.decryptable_available_balance =
724731
new_source_decryptable_available_balance;

0 commit comments

Comments
 (0)