From e366a899582daca724ede47a3346ceeffad945ff Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Thu, 11 Apr 2024 17:01:37 +0900 Subject: [PATCH] update `FeeSigmaProof` to `PercentageWithCapProof` in the `zk_token_elgamal` module --- zk-token-sdk/src/instruction/fee_sigma.rs | 2 +- zk-token-sdk/src/instruction/transfer/with_fee.rs | 2 +- zk-token-sdk/src/zk_token_elgamal/pod/mod.rs | 4 ++-- .../src/zk_token_elgamal/pod/sigma_proofs.rs | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zk-token-sdk/src/instruction/fee_sigma.rs b/zk-token-sdk/src/instruction/fee_sigma.rs index 4b4852dc5a879d..f72afd54ff8bc3 100644 --- a/zk-token-sdk/src/instruction/fee_sigma.rs +++ b/zk-token-sdk/src/instruction/fee_sigma.rs @@ -36,7 +36,7 @@ use { pub struct FeeSigmaProofData { pub context: FeeSigmaProofContext, - pub proof: pod::FeeSigmaProof, + pub proof: pod::PercentageWithCapProof, } /// The context data needed to verify a pubkey validity proof. diff --git a/zk-token-sdk/src/instruction/transfer/with_fee.rs b/zk-token-sdk/src/instruction/transfer/with_fee.rs index bf7c5a99ca69e1..5b5c0c1d9ab79c 100644 --- a/zk-token-sdk/src/instruction/transfer/with_fee.rs +++ b/zk-token-sdk/src/instruction/transfer/with_fee.rs @@ -459,7 +459,7 @@ pub struct TransferWithFeeProof { pub claimed_commitment: pod::PedersenCommitment, pub equality_proof: pod::CiphertextCommitmentEqualityProof, pub ciphertext_amount_validity_proof: pod::BatchedGroupedCiphertext2HandlesValidityProof, - pub fee_sigma_proof: pod::FeeSigmaProof, + pub fee_sigma_proof: pod::PercentageWithCapProof, pub fee_ciphertext_validity_proof: pod::BatchedGroupedCiphertext2HandlesValidityProof, pub range_proof: pod::RangeProofU256, } diff --git a/zk-token-sdk/src/zk_token_elgamal/pod/mod.rs b/zk-token-sdk/src/zk_token_elgamal/pod/mod.rs index d782672c8cf55c..a40a2d42ec7b90 100644 --- a/zk-token-sdk/src/zk_token_elgamal/pod/mod.rs +++ b/zk-token-sdk/src/zk_token_elgamal/pod/mod.rs @@ -22,8 +22,8 @@ pub use { range_proof::{RangeProofU128, RangeProofU256, RangeProofU64}, sigma_proofs::{ BatchedGroupedCiphertext2HandlesValidityProof, CiphertextCiphertextEqualityProof, - CiphertextCommitmentEqualityProof, FeeSigmaProof, GroupedCiphertext2HandlesValidityProof, - PubkeyValidityProof, ZeroBalanceProof, + CiphertextCommitmentEqualityProof, GroupedCiphertext2HandlesValidityProof, + PercentageWithCapProof, PubkeyValidityProof, ZeroBalanceProof, }, }; diff --git a/zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs b/zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs index 07f03f5912fcf7..8b1327378f0477 100644 --- a/zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs +++ b/zk-token-sdk/src/zk_token_elgamal/pod/sigma_proofs.rs @@ -28,7 +28,7 @@ const BATCHED_GROUPED_CIPHERTEXT_2_HANDLES_VALIDITY_PROOF_LEN: usize = 160; const ZERO_BALANCE_PROOF_LEN: usize = 96; /// Byte length of a fee sigma proof -const FEE_SIGMA_PROOF_LEN: usize = 256; +const PERCENTAGE_WITH_CAP_PROOF_LEN: usize = 256; /// Byte length of a public key validity proof const PUBKEY_VALIDITY_PROOF_LEN: usize = 64; @@ -152,23 +152,23 @@ impl TryFrom for DecodedZeroBalanceProof { } } -/// The `FeeSigmaProof` type as a `Pod`. +/// The `PercentageWithCapProof` type as a `Pod`. #[derive(Clone, Copy, Pod, Zeroable)] #[repr(transparent)] -pub struct FeeSigmaProof(pub [u8; FEE_SIGMA_PROOF_LEN]); +pub struct PercentageWithCapProof(pub [u8; PERCENTAGE_WITH_CAP_PROOF_LEN]); #[cfg(not(target_os = "solana"))] -impl From for FeeSigmaProof { +impl From for PercentageWithCapProof { fn from(decoded_proof: DecodedPercentageWithCapProof) -> Self { Self(decoded_proof.to_bytes()) } } #[cfg(not(target_os = "solana"))] -impl TryFrom for DecodedPercentageWithCapProof { +impl TryFrom for DecodedPercentageWithCapProof { type Error = FeeSigmaProofVerificationError; - fn try_from(pod_proof: FeeSigmaProof) -> Result { + fn try_from(pod_proof: PercentageWithCapProof) -> Result { Self::from_bytes(&pod_proof.0) } }