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

Commit e7b7900

Browse files
committed
re-organize constants
1 parent 349339d commit e7b7900

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ use {
2222
};
2323

2424
const MAX_FEE_BASIS_POINTS: u64 = 10_000;
25+
const REMAINING_BALANCE_BIT_LENGTH: u8 = 64;
26+
const TRANSFER_AMOUNT_LO_BIT_LENGTH: u8 = 16;
27+
const TRANSFER_AMOUNT_HI_BIT_LENGTH: u8 = 32;
28+
const DELTA_BIT_LENGTH: u8 = 48;
29+
const FEE_AMOUNT_LO_BIT_LENGTH: u8 = 16;
30+
const FEE_AMOUNT_HI_BIT_LENGTH: u8 = 32;
2531

2632
/// The transfer public keys associated with a transfer with fee.
2733
pub struct TransferWithFeePubkeys {
@@ -181,13 +187,6 @@ impl TransferWithFeeProofContext {
181187
}
182188

183189
// check that the range proof was created for the correct number of bits
184-
const REMAINING_BALANCE_BIT_LENGTH: u8 = 64;
185-
const TRANSFER_AMOUNT_LO_BIT_LENGTH: u8 = 16;
186-
const TRANSFER_AMOUNT_HI_BIT_LENGTH: u8 = 32;
187-
const DELTA_BIT_LENGTH: u8 = 48;
188-
const FEE_AMOUNT_LO_BIT_LENGTH: u8 = 16;
189-
const FEE_AMOUNT_HI_BIT_LENGTH: u8 = 32;
190-
191190
let expected_bit_lengths = [
192191
REMAINING_BALANCE_BIT_LENGTH,
193192
TRANSFER_AMOUNT_LO_BIT_LENGTH,
@@ -306,7 +305,6 @@ fn verify_delta_commitment(
306305
ristretto::multiply_ristretto(&transfer_fee_basis_points_scalar, &transfer_amount_point)
307306
.ok_or(TokenProofExtractionError::CurveArithmetic)?;
308307

309-
const MAX_FEE_BASIS_POINTS: u64 = 10_000;
310308
let max_fee_basis_points_scalar = u64_to_scalar(MAX_FEE_BASIS_POINTS);
311309
let fee_point: PodRistrettoPoint = commitment_to_ristretto(fee_commitment);
312310
let scaled_fee_point = ristretto::multiply_ristretto(&max_fee_basis_points_scalar, &fee_point)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const ONE_IN_BASIS_POINTS: u128 = MAX_FEE_BASIS_POINTS as u128;
2727
const FEE_AMOUNT_LO_BITS: usize = 16;
2828
const FEE_AMOUNT_HI_BITS: usize = 32;
2929

30+
const REMAINING_BALANCE_BIT_LENGTH: usize = 64;
31+
const DELTA_BIT_LENGTH: usize = 48;
32+
3033
#[allow(clippy::too_many_arguments)]
3134
pub fn transfer_with_fee_split_proof_data(
3235
current_available_balance: &ElGamalCiphertext,
@@ -240,10 +243,6 @@ pub fn transfer_with_fee_split_proof_data(
240243
.map_err(TokenProofGenerationError::from)?;
241244

242245
// generate range proof data
243-
const REMAINING_BALANCE_BIT_LENGTH: usize = 64;
244-
const DELTA_BIT_LENGTH: usize = 48;
245-
const MAX_FEE_BASIS_POINTS: u64 = 10_000;
246-
247246
let delta_fee_complement = MAX_FEE_BASIS_POINTS
248247
.checked_sub(delta_fee)
249248
.ok_or(TokenProofGenerationError::FeeCalculation)?;

0 commit comments

Comments
 (0)