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

Commit 7ff9bf2

Browse files
committed
organize transfer proof data using structs
1 parent 31931a7 commit 7ff9bf2

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

token/confidential-transfer/proof-generation/src/transfer.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ use {
2121
/// token transfer
2222
const RANGE_PROOF_PADDING_BIT_LENGTH: usize = 16;
2323

24+
/// The proof data required for a confidential transfer instruction when the mint is not extended
25+
/// for fees
26+
pub struct TransferProofData {
27+
pub equality_proof_data: CiphertextCommitmentEqualityProofData,
28+
pub ciphertext_validity_proof_data: BatchedGroupedCiphertext3HandlesValidityProofData,
29+
pub range_proof_data: BatchedRangeProofU128Data,
30+
}
31+
2432
pub fn transfer_split_proof_data(
2533
current_available_balance: &ElGamalCiphertext,
2634
current_decryptable_available_balance: &AeCiphertext,
@@ -29,14 +37,7 @@ pub fn transfer_split_proof_data(
2937
aes_key: &AeKey,
3038
destination_elgamal_pubkey: &ElGamalPubkey,
3139
auditor_elgamal_pubkey: Option<&ElGamalPubkey>,
32-
) -> Result<
33-
(
34-
CiphertextCommitmentEqualityProofData,
35-
BatchedGroupedCiphertext3HandlesValidityProofData,
36-
BatchedRangeProofU128Data,
37-
),
38-
TokenProofGenerationError,
39-
> {
40+
) -> Result<TransferProofData, TokenProofGenerationError> {
4041
let default_auditor_pubkey = ElGamalPubkey::default();
4142
let auditor_elgamal_pubkey = auditor_elgamal_pubkey.unwrap_or(&default_auditor_pubkey);
4243

@@ -149,9 +150,9 @@ pub fn transfer_split_proof_data(
149150
)
150151
.map_err(TokenProofGenerationError::from)?;
151152

152-
Ok((
153+
Ok(TransferProofData {
153154
equality_proof_data,
154155
ciphertext_validity_proof_data,
155156
range_proof_data,
156-
))
157+
})
157158
}

token/confidential-transfer/proof-generation/src/transfer_with_fee.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ const FEE_AMOUNT_HI_BITS: usize = 32;
3030
const REMAINING_BALANCE_BIT_LENGTH: usize = 64;
3131
const DELTA_BIT_LENGTH: usize = 48;
3232

33+
/// The proof data required for a confidential transfer instruction when the mint is extended for
34+
/// fees
35+
pub struct TransferWithFeeProofData {
36+
pub equality_proof_data: CiphertextCommitmentEqualityProofData,
37+
pub transfer_amount_ciphertext_validity_proof_data:
38+
BatchedGroupedCiphertext3HandlesValidityProofData,
39+
pub percentage_with_cap_proof_data: PercentageWithCapProofData,
40+
pub fee_ciphertext_validity_proof_data: BatchedGroupedCiphertext2HandlesValidityProofData,
41+
pub range_proof_data: BatchedRangeProofU256Data,
42+
}
43+
3344
#[allow(clippy::too_many_arguments)]
3445
pub fn transfer_with_fee_split_proof_data(
3546
current_available_balance: &ElGamalCiphertext,
@@ -42,16 +53,7 @@ pub fn transfer_with_fee_split_proof_data(
4253
withdraw_withheld_authority_elgamal_pubkey: &ElGamalPubkey,
4354
fee_rate_basis_points: u16,
4455
maximum_fee: u64,
45-
) -> Result<
46-
(
47-
CiphertextCommitmentEqualityProofData,
48-
BatchedGroupedCiphertext3HandlesValidityProofData,
49-
PercentageWithCapProofData,
50-
BatchedGroupedCiphertext2HandlesValidityProofData,
51-
BatchedRangeProofU256Data,
52-
),
53-
TokenProofGenerationError,
54-
> {
56+
) -> Result<TransferWithFeeProofData, TokenProofGenerationError> {
5557
let default_auditor_pubkey = ElGamalPubkey::default();
5658
let auditor_elgamal_pubkey = auditor_elgamal_pubkey.unwrap_or(&default_auditor_pubkey);
5759

@@ -294,13 +296,13 @@ pub fn transfer_with_fee_split_proof_data(
294296
)
295297
.map_err(TokenProofGenerationError::from)?;
296298

297-
Ok((
299+
Ok(TransferWithFeeProofData {
298300
equality_proof_data,
299301
transfer_amount_ciphertext_validity_proof_data,
300302
percentage_with_cap_proof_data,
301303
fee_ciphertext_validity_proof_data,
302304
range_proof_data,
303-
))
305+
})
304306
}
305307

306308
fn calculate_fee(transfer_amount: u64, fee_rate_basis_points: u16) -> Option<(u64, u64)> {

0 commit comments

Comments
 (0)