Skip to content

Commit

Permalink
update FeeSigmaProof to PercentageWithCapProof in the `sigma_proo…
Browse files Browse the repository at this point in the history
…fs` modules
  • Loading branch information
samkim-crypto committed Apr 11, 2024
1 parent 01314a4 commit 1a62734
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions zk-token-sdk/src/instruction/fee_sigma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use {
crate::{
encryption::pedersen::{PedersenCommitment, PedersenOpening},
errors::{ProofGenerationError, ProofVerificationError},
sigma_proofs::fee_proof::FeeSigmaProof,
sigma_proofs::fee_proof::PercentageWithCapProof,
transcript::TranscriptProtocol,
},
merlin::Transcript,
Expand Down Expand Up @@ -87,7 +87,7 @@ impl FeeSigmaProofData {

let mut transcript = context.new_transcript();

let proof = FeeSigmaProof::new(
let proof = PercentageWithCapProof::new(
(fee_amount, fee_commitment, fee_opening),
(delta_fee, delta_commitment, delta_opening),
(claimed_commitment, claimed_opening),
Expand Down Expand Up @@ -115,7 +115,7 @@ impl ZkProofData<FeeSigmaProofContext> for FeeSigmaProofData {
let delta_commitment = self.context.delta_commitment.try_into()?;
let claimed_commitment = self.context.claimed_commitment.try_into()?;
let max_fee = self.context.max_fee.into();
let proof: FeeSigmaProof = self.proof.try_into()?;
let proof: PercentageWithCapProof = self.proof.try_into()?;

proof
.verify(
Expand Down
6 changes: 3 additions & 3 deletions zk-token-sdk/src/instruction/transfer/with_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use {
sigma_proofs::{
batched_grouped_ciphertext_validity_proof::BatchedGroupedCiphertext2HandlesValidityProof,
ciphertext_commitment_equality_proof::CiphertextCommitmentEqualityProof,
fee_proof::FeeSigmaProof,
fee_proof::PercentageWithCapProof,
},
transcript::TranscriptProtocol,
},
Expand Down Expand Up @@ -547,7 +547,7 @@ impl TransferWithFeeProof {
transcript.append_commitment(b"commitment-delta", &pod_delta_commitment);

// generate fee sigma proof
let fee_sigma_proof = FeeSigmaProof::new(
let fee_sigma_proof = PercentageWithCapProof::new(
(
combined_fee_amount,
&combined_fee_commitment,
Expand Down Expand Up @@ -656,7 +656,7 @@ impl TransferWithFeeProof {
let equality_proof: CiphertextCommitmentEqualityProof = self.equality_proof.try_into()?;
let ciphertext_amount_validity_proof: BatchedGroupedCiphertext2HandlesValidityProof =
self.ciphertext_amount_validity_proof.try_into()?;
let fee_sigma_proof: FeeSigmaProof = self.fee_sigma_proof.try_into()?;
let fee_sigma_proof: PercentageWithCapProof = self.fee_sigma_proof.try_into()?;
let fee_ciphertext_validity_proof: BatchedGroupedCiphertext2HandlesValidityProof =
self.fee_ciphertext_validity_proof.try_into()?;
let range_proof: RangeProof = self.range_proof.try_into()?;
Expand Down
4 changes: 2 additions & 2 deletions zk-token-sdk/src/sigma_proofs/fee_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const FEE_SIGMA_PROOF_LEN: usize = UNIT_LEN * 8;
/// `fee_equality_proof` is simulated. If the fee is smaller than the maximum fee bound, the
/// `fee_equality_proof` is properly generated and `fee_max_proof` is simulated.
#[derive(Clone)]
pub struct FeeSigmaProof {
pub struct PercentageWithCapProof {
/// Proof that the committed fee amount equals the maximum fee bound
fee_max_proof: FeeMaxProof,

Expand All @@ -53,7 +53,7 @@ pub struct FeeSigmaProof {

#[allow(non_snake_case, dead_code)]
#[cfg(not(target_os = "solana"))]
impl FeeSigmaProof {
impl PercentageWithCapProof {
/// Creates a fee sigma proof assuming that the committed fee is greater than the maximum fee
/// bound.
///
Expand Down
8 changes: 4 additions & 4 deletions zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::sigma_proofs::{
batched_grouped_ciphertext_validity_proof::BatchedGroupedCiphertext2HandlesValidityProof as DecodedBatchedGroupedCiphertext2HandlesValidityProof,
ciphertext_ciphertext_equality_proof::CiphertextCiphertextEqualityProof as DecodedCiphertextCiphertextEqualityProof,
ciphertext_commitment_equality_proof::CiphertextCommitmentEqualityProof as DecodedCiphertextCommitmentEqualityProof,
errors::*, fee_proof::FeeSigmaProof as DecodedFeeSigmaProof,
errors::*, fee_proof::PercentageWithCapProof as DecodedPercentageWithCapProof,
grouped_ciphertext_validity_proof::GroupedCiphertext2HandlesValidityProof as DecodedGroupedCiphertext2HandlesValidityProof,
pubkey_proof::PubkeyValidityProof as DecodedPubkeyValidityProof,
zero_balance_proof::ZeroBalanceProof as DecodedZeroBalanceProof,
Expand Down Expand Up @@ -158,14 +158,14 @@ impl TryFrom<ZeroBalanceProof> for DecodedZeroBalanceProof {
pub struct FeeSigmaProof(pub [u8; FEE_SIGMA_PROOF_LEN]);

#[cfg(not(target_os = "solana"))]
impl From<DecodedFeeSigmaProof> for FeeSigmaProof {
fn from(decoded_proof: DecodedFeeSigmaProof) -> Self {
impl From<DecodedPercentageWithCapProof> for FeeSigmaProof {
fn from(decoded_proof: DecodedPercentageWithCapProof) -> Self {
Self(decoded_proof.to_bytes())
}
}

#[cfg(not(target_os = "solana"))]
impl TryFrom<FeeSigmaProof> for DecodedFeeSigmaProof {
impl TryFrom<FeeSigmaProof> for DecodedPercentageWithCapProof {
type Error = FeeSigmaProofVerificationError;

fn try_from(pod_proof: FeeSigmaProof) -> Result<Self, Self::Error> {
Expand Down

0 comments on commit 1a62734

Please sign in to comment.