diff --git a/zk-sdk/Cargo.toml b/zk-sdk/Cargo.toml index f517f1a..8a77195 100644 --- a/zk-sdk/Cargo.toml +++ b/zk-sdk/Cargo.toml @@ -22,6 +22,7 @@ solana-instruction = { workspace = true, features = ["std"] } solana-pubkey = { workspace = true, features = ["bytemuck"] } solana-sdk-ids = { workspace = true } thiserror = { workspace = true } +sha3 = { workspace = true } [target.'cfg(not(target_os = "solana"))'.dependencies] aes-gcm-siv = { workspace = true } diff --git a/zk-sdk/src/range_proof/errors.rs b/zk-sdk/src/range_proof/errors.rs index f3c304f..9e85cca 100644 --- a/zk-sdk/src/range_proof/errors.rs +++ b/zk-sdk/src/range_proof/errors.rs @@ -36,6 +36,8 @@ pub enum RangeProofVerificationError { MaximumGeneratorLengthExceeded, #[error("commitments and bit lengths vectors have different lengths")] VectorLengthMismatch, + + } #[cfg(not(target_os = "solana"))] diff --git a/zk-sdk/src/zk_elgamal_proof_program/errors.rs b/zk-sdk/src/zk_elgamal_proof_program/errors.rs index 842e163..ded38de 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/errors.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/errors.rs @@ -39,6 +39,8 @@ pub enum ProofVerificationError { IllegalCommitmentLength, #[error("illegal amount bit length")] IllegalAmountBitLength, + #[error("ciphertext mismatch")] + CiphertextMismatch, } #[derive(Clone, Debug, Eq, PartialEq)] diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u256.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u256.rs index c754bad..fe40e35 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u256.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/batched_range_proof_u256.rs @@ -47,6 +47,8 @@ impl BatchedRangeProofU256Data { amounts: Vec, bit_lengths: Vec, openings: Vec<&PedersenOpening>, + + ) -> Result { // Range proof on 256 bit length could potentially result in an unexpected behavior and // therefore, restrict the bit length to be at most 128. This check is not needed for the @@ -90,7 +92,10 @@ impl ZkProofData for BatchedRangeProofU256Data { fn verify_proof(&self) -> Result<(), ProofVerificationError> { let (commitments, bit_lengths) = self.context.try_into()?; let num_commitments = commitments.len(); - + // checks the context ciphertext is same as given on-chain + // if ciphertext != onchain_ciphertext { + // return Err(ProofVerificationError::CiphertextMismatch); + // } // This check is unique to the 256-bit proof. For 64-bit and 128-bit proofs, // the total sum constraint already guarantees that no single bit length can // exceed 128. However, for a 256-bit proof, bit lengths can sum to 256 @@ -107,6 +112,7 @@ impl ZkProofData for BatchedRangeProofU256Data { return Err(ProofVerificationError::IllegalCommitmentLength); } + let mut transcript = self.context_data().new_transcript(); let proof: RangeProof = self.proof.try_into()?; diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/mod.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/mod.rs index a003a21..74d57d0 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/mod.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/batched_range_proof/mod.rs @@ -54,6 +54,8 @@ const MAX_SINGLE_BIT_LENGTH: usize = 128; pub struct BatchedRangeProofContext { pub commitments: [PodPedersenCommitment; MAX_COMMITMENTS], pub bit_lengths: [u8; MAX_COMMITMENTS], + + } #[allow(non_snake_case)] @@ -104,6 +106,7 @@ impl BatchedRangeProofContext { Ok(BatchedRangeProofContext { commitments: pod_commitments, bit_lengths: pod_bit_lengths, + }) } } @@ -128,6 +131,7 @@ impl TryInto<(Vec, Vec)> for BatchedRangeProofContext .map(|bit_length| bit_length as usize) .collect(); + Ok((commitments, bit_lengths)) } } diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/mod.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/mod.rs new file mode 100644 index 0000000..223e311 --- /dev/null +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/mod.rs @@ -0,0 +1,145 @@ +//! The batched range proof instructions. +//! +//! A batched range proof is a cryptographic method that proves a set of committed values +//! fall within specified bit-ranges, without revealing the values themselves. It is more +//! efficient than verifying individual range proofs for each commitment. +//! +//! This module provides three instructions for batched range proofs, each corresponding to a +//! different total bit length: +//! - `VerifyBatchedRangeProof64`: For proofs where the sum of bit lengths is 64. +//! - `VerifyBatchedRangeProof128`: For proofs where the sum of bit lengths is 128. +//! - `VerifyBatchedRangeProof256`: For proofs where the sum of bit lengths is 256. +//! +//! For example, to generate a batched range proof for a sequence of commitments `[C_1, C_2, C_3]` +//! with corresponding bit-lengths `[32, 32, 64]`, one must use `VerifyBatchedRangeProof128`, +//! since the sum of bit-lengths is `32 + 32 + 64 = 128`. +//! +//! The maximum number of commitments that can be batched together is fixed at 8. Each individual +//! bit length `n_i` must be at most 128. + +// pub mod batched_range_proof_u128; +// pub mod batched_range_proof_u256; +// pub mod batched_range_proof_u64; +use sha3::{Sha3_256, Digest}; +pub mod range_proof; +#[allow(dead_code)] + +use crate::encryption::pod::pedersen::PodPedersenCommitment; +#[cfg(not(target_os = "solana"))] +use { + crate::{ + encryption::pedersen::{PedersenCommitment, PedersenOpening}, + zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError}, + }, + bytemuck::{bytes_of, Zeroable}, + curve25519_dalek::traits::IsIdentity, + merlin::Transcript, + std::convert::TryInto, +}; + +/// The maximum number of Pedersen commitments that can be processed in a single batched range proof. +const MAX_COMMITMENTS: usize = 8; + +/// A bit length in a batched range proof must be at most 128. +/// +/// A 256-bit range proof on a single Pedersen commitment is meaningless and hence enforce an upper +/// bound as the largest power-of-two number less than 256. +// #[cfg(not(target_os = "solana"))] +// const MAX_SINGLE_BIT_LENGTH: usize = 128; + +/// The context data needed to verify a range-proof for a Pedersen committed value. +/// +/// This struct holds the public information that a batched range proof certifies. It includes the +/// Pedersen commitments and their corresponding bit lengths. This context is shared by all +/// `VerifyBatchedRangeProof{N}` instructions. +#[derive(Clone, Copy,bytemuck_derive::Pod, bytemuck_derive::Zeroable)] +#[repr(C)] +pub struct CiphertextRangeProofContext { + pub commitments: [PodPedersenCommitment; MAX_COMMITMENTS], + pub bit_lengths: [u8; MAX_COMMITMENTS], + pub ciphertext_hash: [u8;32] + +} + +#[allow(non_snake_case)] +#[cfg(not(target_os = "solana"))] +impl CiphertextRangeProofContext { + fn new_transcript(&self) -> Transcript { + let mut transcript = Transcript::new(b"batched-range-proof-instruction"); + transcript.append_message(b"ciphertext_hash", bytes_of(&self.ciphertext_hash)); + transcript.append_message(b"commitments", bytes_of(&self.commitments)); + transcript.append_message(b"bit-lengths", bytes_of(&self.bit_lengths)); + transcript + } + + fn new( + commitments: &[&PedersenCommitment], + amounts: &[u64], + bit_lengths: &[usize], + openings: &[&PedersenOpening], + ciphertext: &Vec + ) -> Result { + // the number of commitments is capped at 8 + let num_commitments = commitments.len(); + if num_commitments > MAX_COMMITMENTS + || num_commitments != amounts.len() + || num_commitments != bit_lengths.len() + || num_commitments != openings.len() + { + return Err(ProofGenerationError::IllegalCommitmentLength); + } + + let mut pod_commitments = [PodPedersenCommitment::zeroed(); MAX_COMMITMENTS]; + for (i, commitment) in commitments.iter().enumerate() { + // all-zero commitment is invalid + // + // this check only exists in the prover logic to enforce safe practice + // identity commitments are not rejected by range proof verification logic itself + if commitment.get_point().is_identity() { + return Err(ProofGenerationError::InvalidCommitment); + } + pod_commitments[i] = PodPedersenCommitment(commitment.to_bytes()); + } + + let mut pod_bit_lengths = [0; MAX_COMMITMENTS]; + for (i, bit_length) in bit_lengths.iter().enumerate() { + pod_bit_lengths[i] = (*bit_length) + .try_into() + .map_err(|_| ProofGenerationError::IllegalAmountBitLength)?; + } + let mut hasher = Sha3_256::new(); + hasher.update(ciphertext); + let ciphertext_hash: [u8; 32] = hasher.finalize().into(); + + Ok(CiphertextRangeProofContext { + commitments: pod_commitments, + bit_lengths: pod_bit_lengths, + ciphertext_hash + }) + } +} + +#[cfg(not(target_os = "solana"))] +impl TryInto<(Vec, Vec, [u8;32])> for CiphertextRangeProofContext { + type Error = ProofVerificationError; + + fn try_into(self) -> Result<(Vec, Vec, [u8;32]), Self::Error> { + let commitments = self + .commitments + .into_iter() + .take_while(|commitment| *commitment != PodPedersenCommitment::zeroed()) + .map(|commitment| commitment.try_into()) + .collect::, _>>() + .map_err(|_| ProofVerificationError::ProofContext)?; + + let bit_lengths: Vec<_> = self + .bit_lengths + .into_iter() + .take(commitments.len()) + .map(|bit_length| bit_length as usize) + .collect(); + + + Ok((commitments, bit_lengths, self.ciphertext_hash)) + } +} diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/range_proof.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/range_proof.rs new file mode 100644 index 0000000..bdc6536 --- /dev/null +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/ciphertext_range_proof/range_proof.rs @@ -0,0 +1,248 @@ +//! The 256-bit batched range proof instruction. + +#[cfg(not(target_os = "solana"))] +use { + crate::{ + encryption::pedersen::{PedersenCommitment, PedersenOpening}, + range_proof::RangeProof, + zk_elgamal_proof_program::{ + errors::{ProofGenerationError, ProofVerificationError}, + + }, + }, + std::convert::TryInto, +}; +use { + crate::{ + range_proof::pod::PodRangeProofU256, + zk_elgamal_proof_program::proof_data::{ + ciphertext_range_proof::CiphertextRangeProofContext , ProofType, ZkProofData, + }, + }, + bytemuck_derive::{Pod, Zeroable}, +}; + + +/// The maximum number of Pedersen commitments that can be processed in a single batched range proof. +const MAX_COMMITMENTS: usize = 8; + +/// A bit length in a batched range proof must be at most 128. +/// +/// A 256-bit range proof on a single Pedersen commitment is meaningless and hence enforce an upper +/// bound as the largest power-of-two number less than 256. +#[cfg(not(target_os = "solana"))] +const MAX_SINGLE_BIT_LENGTH: usize = 128; + + +#[cfg(not(target_os = "solana"))] +const BATCHED_RANGE_PROOF_U256_BIT_LENGTH: usize = 256; + +/// The instruction data that is needed for the +/// `ProofInstruction::BatchedRangeProofU256Data` instruction. +/// +/// It includes the cryptographic proof as well as the context data information needed to verify +/// the proof. +#[derive(Clone, Copy, Pod, Zeroable)] +#[repr(C)] +pub struct BatchedRangeProofU256Data { + /// The context data for a batched range proof + pub context: CiphertextRangeProofContext , + + /// The batched range proof + pub proof: PodRangeProofU256, +} + +#[cfg(not(target_os = "solana"))] +impl BatchedRangeProofU256Data { + pub fn new( + commitments: Vec<&PedersenCommitment>, + amounts: Vec, + bit_lengths: Vec, + openings: Vec<&PedersenOpening>, + ciphertext: &Vec + + + ) -> Result { + // Range proof on 256 bit length could potentially result in an unexpected behavior and + // therefore, restrict the bit length to be at most 128. This check is not needed for the + // `BatchedRangeProofU64` or `BatchedRangeProofU128`. + if bit_lengths + .iter() + .any(|length| *length > MAX_SINGLE_BIT_LENGTH) + { + return Err(ProofGenerationError::IllegalCommitmentLength); + } + + // the sum of the bit lengths must be 256 + let batched_bit_length = bit_lengths + .iter() + .try_fold(0_usize, |acc, &x| acc.checked_add(x)) + .ok_or(ProofGenerationError::IllegalAmountBitLength)?; + if batched_bit_length != BATCHED_RANGE_PROOF_U256_BIT_LENGTH { + return Err(ProofGenerationError::IllegalAmountBitLength); + } + + let context = + CiphertextRangeProofContext ::new(&commitments, &amounts, &bit_lengths, &openings, &ciphertext)?; + + let mut transcript = context.new_transcript(); + let proof = RangeProof::new(amounts, bit_lengths, openings, &mut transcript)? + .try_into() + .map_err(|_| ProofGenerationError::ProofLength)?; + + Ok(Self { context, proof }) + } +} + +impl ZkProofData for BatchedRangeProofU256Data { + const PROOF_TYPE: ProofType = ProofType::BatchedRangeProofU256; + + fn context_data(&self) -> &CiphertextRangeProofContext { + &self.context + } + + #[cfg(not(target_os = "solana"))] + fn verify_proof(&self , onchain_ciphertext_hash: &[u8;32]) -> Result<(), ProofVerificationError> { + let (commitments, bit_lengths, ciphertext_hash) = self.context.try_into()?; + let num_commitments = commitments.len(); + // checks the context ciphertext is same as given on-chain + if &ciphertext_hash != onchain_ciphertext_hash { + return Err(ProofVerificationError::CiphertextMismatch); + } + // This check is unique to the 256-bit proof. For 64-bit and 128-bit proofs, + // the total sum constraint already guarantees that no single bit length can + // exceed 128. However, for a 256-bit proof, bit lengths can sum to 256 + // while containing a value greater than 128 (e.g., [160, 96]), so this + // must be explicitly checked. + if bit_lengths + .iter() + .any(|length| *length > MAX_SINGLE_BIT_LENGTH) + { + return Err(ProofVerificationError::IllegalCommitmentLength); + } + + if num_commitments > MAX_COMMITMENTS || num_commitments != bit_lengths.len() { + return Err(ProofVerificationError::IllegalCommitmentLength); + } + + + let mut transcript = self.context_data().new_transcript(); + let proof: RangeProof = self.proof.try_into()?; + + proof + .verify(commitments.iter().collect(), bit_lengths, &mut transcript) + .map_err(|e| e.into()) + } +} + +#[cfg(test)] +mod test { + use { + super::*, + crate::{ + encryption::pedersen::Pedersen, range_proof::errors::RangeProofVerificationError, + zk_elgamal_proof_program::errors::ProofVerificationError, + }, + + }; + use sha3::{Sha3_256, Digest}; + + #[test] + fn test_batched_range_proof_256_instruction_correctness() { + let amount_1 = 100_u64; + let amount_2 = 77_u64; + let amount_3 = 99_u64; + let amount_4 = 99_u64; + let amount_5 = 11_u64; + let amount_6 = 33_u64; + let amount_7 = 99_u64; + let amount_8 = 99_u64; + + let (commitment_1, opening_1) = Pedersen::new(amount_1); + let (commitment_2, opening_2) = Pedersen::new(amount_2); + let (commitment_3, opening_3) = Pedersen::new(amount_3); + let (commitment_4, opening_4) = Pedersen::new(amount_4); + let (commitment_5, opening_5) = Pedersen::new(amount_5); + let (commitment_6, opening_6) = Pedersen::new(amount_6); + let (commitment_7, opening_7) = Pedersen::new(amount_7); + let (commitment_8, opening_8) = Pedersen::new(amount_8); + + // // Create dummy ciphertext data for testing + let ciphertext: Vec = vec![1u8; 32]; + let mut hasher = Sha3_256::new(); + hasher.update(&ciphertext); + let ciphertext_hash: [u8; 32] = hasher.finalize().into(); + + + let proof_data = BatchedRangeProofU256Data::new( + vec![ + &commitment_1, + &commitment_2, + &commitment_3, + &commitment_4, + &commitment_5, + &commitment_6, + &commitment_7, + &commitment_8, + ], + vec![ + amount_1, amount_2, amount_3, amount_4, amount_5, amount_6, amount_7, amount_8, + ], + vec![32, 32, 32, 32, 32, 32, 32, 32], + vec![ + &opening_1, &opening_2, &opening_3, &opening_4, &opening_5, &opening_6, &opening_7, + &opening_8, + ], + &ciphertext, // Added missing ciphertext parameter + ) + .unwrap(); + + assert!(proof_data.verify_proof(&ciphertext_hash).is_ok()); // Added ciphertext parameter + + let amount_1 = 4294967296_u64; // not representable as a 32-bit number + let amount_2 = 77_u64; + let amount_3 = 99_u64; + let amount_4 = 99_u64; + let amount_5 = 11_u64; + let amount_6 = 33_u64; + let amount_7 = 99_u64; + let amount_8 = 99_u64; + + let (commitment_1, opening_1) = Pedersen::new(amount_1); + let (commitment_2, opening_2) = Pedersen::new(amount_2); + let (commitment_3, opening_3) = Pedersen::new(amount_3); + let (commitment_4, opening_4) = Pedersen::new(amount_4); + let (commitment_5, opening_5) = Pedersen::new(amount_5); + let (commitment_6, opening_6) = Pedersen::new(amount_6); + let (commitment_7, opening_7) = Pedersen::new(amount_7); + let (commitment_8, opening_8) = Pedersen::new(amount_8); + + let proof_data = BatchedRangeProofU256Data::new( + vec![ + &commitment_1, + &commitment_2, + &commitment_3, + &commitment_4, + &commitment_5, + &commitment_6, + &commitment_7, + &commitment_8, + ], + vec![ + amount_1, amount_2, amount_3, amount_4, amount_5, amount_6, amount_7, amount_8, + ], + vec![32, 32, 32, 32, 32, 32, 32, 32], + vec![ + &opening_1, &opening_2, &opening_3, &opening_4, &opening_5, &opening_6, &opening_7, + &opening_8, + ], + &ciphertext, // Added missing ciphertext parameter + ) + .unwrap(); + + assert_eq!( + proof_data.verify_proof(&ciphertext_hash).unwrap_err(), // Added ciphertext parameter + ProofVerificationError::RangeProof(RangeProofVerificationError::AlgebraicRelation), + ); + } +} \ No newline at end of file diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/mod.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/mod.rs index 3d061bd..f1b5b41 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/proof_data/mod.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/mod.rs @@ -5,61 +5,67 @@ use { num_derive::{FromPrimitive, ToPrimitive}, }; -pub mod batched_grouped_ciphertext_validity; -pub mod batched_range_proof; -pub mod ciphertext_ciphertext_equality; -pub mod ciphertext_commitment_equality; +// pub mod batched_grouped_ciphertext_validity; +// pub mod batched_range_proof; +// pub mod ciphertext_ciphertext_equality; +// pub mod ciphertext_commitment_equality; pub mod errors; -pub mod grouped_ciphertext_validity; -pub mod percentage_with_cap; +// pub mod grouped_ciphertext_validity; +// pub mod percentage_with_cap; pub mod pod; -pub mod pubkey_validity; -pub mod zero_ciphertext; +// pub mod pubkey_validity; +// pub mod zero_ciphertext; +pub mod ciphertext_range_proof; -pub use { - batched_grouped_ciphertext_validity::{ - BatchedGroupedCiphertext2HandlesValidityProofContext, - BatchedGroupedCiphertext2HandlesValidityProofData, - BatchedGroupedCiphertext3HandlesValidityProofContext, - BatchedGroupedCiphertext3HandlesValidityProofData, - }, - batched_range_proof::{ - batched_range_proof_u128::BatchedRangeProofU128Data, - batched_range_proof_u256::BatchedRangeProofU256Data, - batched_range_proof_u64::BatchedRangeProofU64Data, BatchedRangeProofContext, - }, - ciphertext_ciphertext_equality::{ - CiphertextCiphertextEqualityProofContext, CiphertextCiphertextEqualityProofData, - }, - ciphertext_commitment_equality::{ - CiphertextCommitmentEqualityProofContext, CiphertextCommitmentEqualityProofData, - }, - grouped_ciphertext_validity::{ - GroupedCiphertext2HandlesValidityProofContext, GroupedCiphertext2HandlesValidityProofData, - GroupedCiphertext3HandlesValidityProofContext, GroupedCiphertext3HandlesValidityProofData, - }, - percentage_with_cap::{PercentageWithCapProofContext, PercentageWithCapProofData}, - pubkey_validity::{PubkeyValidityProofContext, PubkeyValidityProofData}, - zero_ciphertext::{ZeroCiphertextProofContext, ZeroCiphertextProofData}, +// pub use { +// batched_grouped_ciphertext_validity::{ +// BatchedGroupedCiphertext2HandlesValidityProofContext, +// BatchedGroupedCiphertext2HandlesValidityProofData, +// BatchedGroupedCiphertext3HandlesValidityProofContext, +// BatchedGroupedCiphertext3HandlesValidityProofData, +// }, +// batched_range_proof::{ +// batched_range_proof_u128::BatchedRangeProofU128Data, +// batched_range_proof_u256::BatchedRangeProofU256Data, +// batched_range_proof_u64::BatchedRangeProofU64Data, BatchedRangeProofContext, +// }, +// ciphertext_ciphertext_equality::{ +// CiphertextCiphertextEqualityProofContext, CiphertextCiphertextEqualityProofData, +// }, +// ciphertext_commitment_equality::{ +// CiphertextCommitmentEqualityProofContext, CiphertextCommitmentEqualityProofData, +// }, +// grouped_ciphertext_validity::{ +// GroupedCiphertext2HandlesValidityProofContext, GroupedCiphertext2HandlesValidityProofData, +// GroupedCiphertext3HandlesValidityProofContext, GroupedCiphertext3HandlesValidityProofData, +// }, +// percentage_with_cap::{PercentageWithCapProofContext, PercentageWithCapProofData}, +// pubkey_validity::{PubkeyValidityProofContext, PubkeyValidityProofData}, +// zero_ciphertext::{ZeroCiphertextProofContext, ZeroCiphertextProofData}, +// }; + +pub use{ + ciphertext_range_proof::{CiphertextRangeProofContext}, }; #[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive, PartialEq, Eq)] #[repr(u8)] pub enum ProofType { /// Empty proof type used to distinguish if a proof context account is initialized - Uninitialized, - ZeroCiphertext, - CiphertextCiphertextEquality, - CiphertextCommitmentEquality, - PubkeyValidity, - PercentageWithCap, - BatchedRangeProofU64, - BatchedRangeProofU128, - BatchedRangeProofU256, - GroupedCiphertext2HandlesValidity, - BatchedGroupedCiphertext2HandlesValidity, - GroupedCiphertext3HandlesValidity, - BatchedGroupedCiphertext3HandlesValidity, + // Uninitialized, + // ZeroCiphertext, + // CiphertextCiphertextEquality, + // CiphertextCommitmentEquality, + // PubkeyValidity, + // PercentageWithCap, + // BatchedRangeProofU64, + // BatchedRangeProofU128, + // BatchedRangeProofU256, + // GroupedCiphertext2HandlesValidity, + // BatchedGroupedCiphertext2HandlesValidity, + // GroupedCiphertext3HandlesValidity, + // BatchedGroupedCiphertext3HandlesValidity, + BatchedRangeProofU256 } pub trait ZkProofData { @@ -68,5 +74,5 @@ pub trait ZkProofData { fn context_data(&self) -> &T; #[cfg(not(target_os = "solana"))] - fn verify_proof(&self) -> Result<(), ProofVerificationError>; + fn verify_proof(&self, ciphertext:&[u8;32]) -> Result<(), ProofVerificationError>; } diff --git a/zk-sdk/src/zk_elgamal_proof_program/proof_data/pod.rs b/zk-sdk/src/zk_elgamal_proof_program/proof_data/pod.rs index 4b5c992..d57c3d1 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/proof_data/pod.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/proof_data/pod.rs @@ -4,6 +4,7 @@ use { num_traits::{FromPrimitive, ToPrimitive}, }; + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Pod, Zeroable)] #[repr(transparent)] pub struct PodProofType(u8); @@ -19,7 +20,7 @@ impl TryFrom for ProofType { FromPrimitive::from_u8(pod.0).ok_or(Self::Error::InvalidProofType) } } - +#[allow(unused_macros)] macro_rules! impl_wasm_to_bytes { (TYPE = $type:ident) => { #[cfg(not(target_os = "solana"))] @@ -39,4 +40,5 @@ macro_rules! impl_wasm_to_bytes { } }; } +#[allow(unused_imports)] pub(crate) use impl_wasm_to_bytes;