diff --git a/bench-templates/src/lib.rs b/bench-templates/src/lib.rs index a9ca68ea..ba212e3e 100644 --- a/bench-templates/src/lib.rs +++ b/bench-templates/src/lib.rs @@ -69,7 +69,7 @@ pub fn commit< LabeledPolynomial::new("test".to_string(), rand_poly(num_vars, rng), None, None); let start = Instant::now(); - let (_, _, _) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); + let (_, _) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); start.elapsed() } @@ -91,7 +91,7 @@ pub fn commitment_size< let labeled_poly = LabeledPolynomial::new("test".to_string(), rand_poly(num_vars, rng), None, None); - let (coms, _, _) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); + let (coms, _) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); coms[0].commitment().serialized_size(Compress::No) } @@ -114,7 +114,7 @@ where let labeled_poly = LabeledPolynomial::new("test".to_string(), rand_poly(num_vars, rng), None, None); - let (coms, states, randomness) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); + let (coms, states) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); let point = P::Point::rand(rng); let start = Instant::now(); @@ -125,7 +125,6 @@ where &point, &mut ChallengeGenerator::new_univariate(&mut test_sponge()), &states, - &randomness, Some(rng), ) .unwrap(); @@ -149,7 +148,7 @@ where let labeled_poly = LabeledPolynomial::new("test".to_string(), rand_poly(num_vars, rng), None, None); - let (coms, states, randomness) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); + let (coms, states) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); let point = P::Point::rand(rng); let proofs = PCS::open( @@ -159,7 +158,6 @@ where &point, &mut ChallengeGenerator::new_univariate(&mut test_sponge()), &states, - &randomness, Some(rng), ) .unwrap(); @@ -187,7 +185,7 @@ where let labeled_poly = LabeledPolynomial::new("test".to_string(), rand_poly(num_vars, rng), None, None); - let (coms, states, randomness) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); + let (coms, states) = PCS::commit(&ck, [&labeled_poly], Some(rng)).unwrap(); let point = P::Point::rand(rng); let claimed_eval = labeled_poly.evaluate(&point); let proof = PCS::open( @@ -197,7 +195,6 @@ where &point, &mut ChallengeGenerator::new_univariate(&mut test_sponge()), &states, - &randomness, Some(rng), ) .unwrap(); diff --git a/poly-commit/src/data_structures.rs b/poly-commit/src/data_structures.rs index 9735d002..b4854f9a 100644 --- a/poly-commit/src/data_structures.rs +++ b/poly-commit/src/data_structures.rs @@ -63,9 +63,6 @@ pub trait PCCommitment: Clone + CanonicalSerialize + CanonicalDeserialize { fn has_degree_bound(&self) -> bool; } -/// Defines the auxiliary data of the commitment -pub trait PCCommitmentState: Clone + Default + CanonicalSerialize + CanonicalDeserialize {} - /// Defines the minimal interface of prepared commitments for any polynomial /// commitment scheme. pub trait PCPreparedCommitment: Clone { @@ -73,9 +70,9 @@ pub trait PCPreparedCommitment: Clone { fn prepare(comm: &UNPREPARED) -> Self; } -/// Defines the minimal interface of commitment randomness for any polynomial -/// commitment scheme. -pub trait PCRandomness: Clone + CanonicalSerialize + CanonicalDeserialize { +/// Defines the minimal interface of commitment state for any polynomial +/// commitment scheme. It might be randomness etc. +pub trait PCCommitmentState: Clone + CanonicalSerialize + CanonicalDeserialize { /// Outputs empty randomness that does not hide the commitment. fn empty() -> Self; diff --git a/poly-commit/src/ipa_pc/data_structures.rs b/poly-commit/src/ipa_pc/data_structures.rs index 7ba56c95..a2cca4d1 100644 --- a/poly-commit/src/ipa_pc/data_structures.rs +++ b/poly-commit/src/ipa_pc/data_structures.rs @@ -146,7 +146,7 @@ pub struct Randomness { pub shifted_rand: Option, } -impl PCRandomness for Randomness { +impl PCCommitmentState for Randomness { fn empty() -> Self { Self { rand: G::ScalarField::zero(), diff --git a/poly-commit/src/ipa_pc/mod.rs b/poly-commit/src/ipa_pc/mod.rs index 800ad480..d5472d9b 100644 --- a/poly-commit/src/ipa_pc/mod.rs +++ b/poly-commit/src/ipa_pc/mod.rs @@ -1,8 +1,7 @@ -use crate::kzg10::CommitmentState; use crate::{BTreeMap, BTreeSet, String, ToString, Vec, CHALLENGE_SIZE}; use crate::{BatchLCProof, DenseUVPolynomial, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; -use crate::{PCCommitterKey, PCRandomness, PCUniversalParams, PolynomialCommitment}; +use crate::{PCCommitmentState, PCCommitterKey, PCUniversalParams, PolynomialCommitment}; use ark_ec::{AffineRepr, CurveGroup, VariableBaseMSM}; use ark_ff::{Field, One, PrimeField, UniformRand, Zero}; @@ -348,8 +347,7 @@ where type CommitterKey = CommitterKey; type VerifierKey = VerifierKey; type Commitment = Commitment; - type CommitmentState = CommitmentState; - type Randomness = Randomness; + type CommitmentState = Randomness; type Proof = Proof; type BatchProof = Vec; type Error = Error; @@ -421,7 +419,6 @@ where ( Vec>, Vec, - Vec, ), Self::Error, > @@ -483,7 +480,7 @@ where } end_timer!(commit_time); - Ok((comms, vec![CommitmentState {}; rands.len()], rands)) + Ok((comms, rands)) } fn open<'a>( @@ -492,13 +489,12 @@ where commitments: impl IntoIterator>, point: &'a P::Point, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result where Self::Commitment: 'a, - Self::Randomness: 'a, + Self::CommitmentState: 'a, P: 'a, { let mut combined_polynomial = P::zero(); @@ -881,12 +877,11 @@ where commitments: impl IntoIterator>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Self::Error> where - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, P: 'a, { @@ -977,7 +972,6 @@ where lc_commitments.iter(), &query_set, opening_challenges, - &vec![CommitmentState {}; lc_randomness.len()], lc_randomness.iter(), rng, )?; diff --git a/poly-commit/src/kzg10/data_structures.rs b/poly-commit/src/kzg10/data_structures.rs index d44efecb..8ae4191a 100644 --- a/poly-commit/src/kzg10/data_structures.rs +++ b/poly-commit/src/kzg10/data_structures.rs @@ -329,11 +329,6 @@ pub struct Commitment( pub E::G1Affine, ); -/// The auxiliary data for KZG commitment is empty. -#[derive(Clone, Default, CanonicalSerialize, CanonicalDeserialize)] -pub struct CommitmentState {} -impl PCCommitmentState for CommitmentState {} - impl PCCommitment for Commitment { #[inline] fn empty() -> Self { @@ -425,7 +420,7 @@ impl> Randomness { } } -impl> PCRandomness for Randomness { +impl> PCCommitmentState for Randomness { fn empty() -> Self { Self { blinding_polynomial: P::zero(), diff --git a/poly-commit/src/kzg10/mod.rs b/poly-commit/src/kzg10/mod.rs index a6ea5752..d4bc9d74 100644 --- a/poly-commit/src/kzg10/mod.rs +++ b/poly-commit/src/kzg10/mod.rs @@ -5,7 +5,7 @@ //! proposed by Kate, Zaverucha, and Goldberg ([KZG10](http://cacr.uwaterloo.ca/techreports/2010/cacr2010-10.pdf)). //! This construction achieves extractability in the algebraic group model (AGM). -use crate::{BTreeMap, Error, LabeledPolynomial, PCRandomness, ToString, Vec}; +use crate::{BTreeMap, Error, LabeledPolynomial, PCCommitmentState, ToString, Vec}; use ark_ec::AffineRepr; use ark_ec::{pairing::Pairing, CurveGroup}; use ark_ec::{scalar_mul::fixed_base::FixedBase, VariableBaseMSM}; diff --git a/poly-commit/src/lib.rs b/poly-commit/src/lib.rs index cbd0a588..48c87625 100644 --- a/poly-commit/src/lib.rs +++ b/poly-commit/src/lib.rs @@ -156,10 +156,8 @@ pub trait PolynomialCommitment, S: Cryptographic type VerifierKey: PCVerifierKey; /// The commitment to a polynomial. type Commitment: PCCommitment + Default; - /// The state of committer + /// The state of commitment type CommitmentState: PCCommitmentState; - /// The commitment randomness. - type Randomness: PCRandomness; /// The evaluation proof for a single point. type Proof: Clone; /// The evaluation proof for a query set. @@ -206,7 +204,6 @@ pub trait PolynomialCommitment, S: Cryptographic ( Vec>, Vec, - Vec, ), Self::Error, > @@ -221,12 +218,10 @@ pub trait PolynomialCommitment, S: Cryptographic point: &'a P::Point, challenge_generator: &mut ChallengeGenerator, states: impl IntoIterator, - rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result where P: 'a, - Self::Randomness: 'a, Self::CommitmentState: 'a, Self::Commitment: 'a; @@ -259,12 +254,10 @@ pub trait PolynomialCommitment, S: Cryptographic query_set: &QuerySet, challenge_generator: &mut ChallengeGenerator, states: impl IntoIterator, - rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result where P: 'a, - Self::Randomness: 'a, Self::CommitmentState: 'a, Self::Commitment: 'a, { @@ -273,12 +266,11 @@ pub trait PolynomialCommitment, S: Cryptographic // the same point, then opening their commitments simultaneously with a // single call to `open` (per point) let rng = &mut crate::optional_rng::OptionalRng(rng); - let poly_rand_st_comm: BTreeMap<_, _> = labeled_polynomials + let poly_st_comm: BTreeMap<_, _> = labeled_polynomials .into_iter() .zip(states) - .zip(rands) .zip(commitments.into_iter()) - .map(|(((poly, st), r), comm)| (poly.label(), (poly, r, st, comm))) + .map(|((poly, st), comm)| (poly.label(), (poly, st, comm))) .collect(); let open_time = start_timer!(|| format!( @@ -306,7 +298,6 @@ pub trait PolynomialCommitment, S: Cryptographic let mut proofs = Vec::new(); for (_point_label, (point, labels)) in query_to_labels_map.into_iter() { let mut query_polys: Vec<&'a LabeledPolynomial<_, _>> = Vec::new(); - let mut query_rands: Vec<&'a Self::Randomness> = Vec::new(); let mut query_states: Vec<&'a Self::CommitmentState> = Vec::new(); let mut query_comms: Vec<&'a LabeledCommitment> = Vec::new(); @@ -314,15 +305,12 @@ pub trait PolynomialCommitment, S: Cryptographic // randomness and actual commitment for each polynomial being // queried at `point` for label in labels { - let (polynomial, rand, state, comm) = - poly_rand_st_comm - .get(label) - .ok_or(Error::MissingPolynomial { - label: label.to_string(), - })?; + let (polynomial, state, comm) = + poly_st_comm.get(label).ok_or(Error::MissingPolynomial { + label: label.to_string(), + })?; query_polys.push(polynomial); - query_rands.push(rand); query_states.push(state); query_comms.push(comm); } @@ -338,7 +326,6 @@ pub trait PolynomialCommitment, S: Cryptographic &point, challenge_generator, query_states, - query_rands, Some(rng), )?; @@ -452,11 +439,9 @@ pub trait PolynomialCommitment, S: Cryptographic query_set: &QuerySet, challenge_generator: &mut ChallengeGenerator, states: impl IntoIterator, - rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Self::Error> where - Self::Randomness: 'a, Self::CommitmentState: 'a, Self::Commitment: 'a, P: 'a, @@ -480,7 +465,6 @@ pub trait PolynomialCommitment, S: Cryptographic &poly_query_set, challenge_generator, states, - rands, rng, )?; Ok(BatchLCProof { @@ -731,7 +715,7 @@ pub mod tests { )?; println!("Trimmed"); - let (comms, states, rands) = PC::commit(&ck, &polynomials, Some(rng))?; + let (comms, states) = PC::commit(&ck, &polynomials, Some(rng))?; let mut query_set = QuerySet::new(); let mut values = Evaluations::new(); @@ -750,7 +734,6 @@ pub mod tests { &query_set, &mut (challenge_gen.clone()), &states, - &rands, Some(rng), )?; let result = PC::batch_check( @@ -865,7 +848,7 @@ pub mod tests { )?; println!("Trimmed"); - let (comms, states, rands) = PC::commit(&ck, &polynomials, Some(rng))?; + let (comms, states) = PC::commit(&ck, &polynomials, Some(rng))?; // Construct query set let mut query_set = QuerySet::new(); @@ -887,7 +870,6 @@ pub mod tests { &query_set, &mut (challenge_gen.clone()), &states, - &rands, Some(rng), )?; let result = PC::batch_check( @@ -1014,7 +996,7 @@ pub mod tests { )?; println!("Trimmed"); - let (comms, states, rands) = PC::commit(&ck, &polynomials, Some(rng))?; + let (comms, states) = PC::commit(&ck, &polynomials, Some(rng))?; // Let's construct our equations let mut linear_combinations = Vec::new(); @@ -1067,7 +1049,6 @@ pub mod tests { &query_set, &mut (challenge_gen.clone()), &states, - &rands, Some(rng), )?; println!("Generated proof"); diff --git a/poly-commit/src/marlin/marlin_pc/data_structures.rs b/poly-commit/src/marlin/marlin_pc/data_structures.rs index 2b09e03a..5d1cdffb 100644 --- a/poly-commit/src/marlin/marlin_pc/data_structures.rs +++ b/poly-commit/src/marlin/marlin_pc/data_structures.rs @@ -1,6 +1,6 @@ use crate::{ - DenseUVPolynomial, PCCommitment, PCCommitterKey, PCPreparedCommitment, PCPreparedVerifierKey, - PCRandomness, PCVerifierKey, Vec, + DenseUVPolynomial, PCCommitment, PCCommitmentState, PCCommitterKey, PCPreparedCommitment, + PCPreparedVerifierKey, PCVerifierKey, Vec, }; use ark_ec::pairing::Pairing; use ark_ec::AdditiveGroup; @@ -360,7 +360,7 @@ impl<'a, F: PrimeField, P: DenseUVPolynomial> AddAssign<(F, &'a Randomness> PCRandomness for Randomness { +impl> PCCommitmentState for Randomness { fn empty() -> Self { Self { rand: kzg10::Randomness::empty(), diff --git a/poly-commit/src/marlin/marlin_pc/mod.rs b/poly-commit/src/marlin/marlin_pc/mod.rs index c10c8680..e69c7392 100644 --- a/poly-commit/src/marlin/marlin_pc/mod.rs +++ b/poly-commit/src/marlin/marlin_pc/mod.rs @@ -1,9 +1,8 @@ -use crate::kzg10::CommitmentState; use crate::{kzg10, marlin::Marlin, PCCommitterKey, CHALLENGE_SIZE}; use crate::{BTreeMap, BTreeSet, ToString, Vec}; use crate::{BatchLCProof, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; -use crate::{PCRandomness, PCUniversalParams, PolynomialCommitment}; +use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment}; use ark_ec::pairing::Pairing; use ark_ec::AffineRepr; use ark_ec::CurveGroup; @@ -67,8 +66,7 @@ where type CommitterKey = CommitterKey; type VerifierKey = VerifierKey; type Commitment = Commitment; - type CommitmentState = CommitmentState; - type Randomness = Randomness; + type CommitmentState = Randomness; type Proof = kzg10::Proof; type BatchProof = Vec; type Error = Error; @@ -183,7 +181,6 @@ where ( Vec>, Vec, - Vec, ), Self::Error, > @@ -245,11 +242,7 @@ where end_timer!(commit_time); } end_timer!(commit_time); - Ok(( - commitments, - vec![CommitmentState {}; randomness.len()], - randomness, - )) + Ok((commitments, randomness)) } /// On input a polynomial `p` and a point `point`, outputs a proof for the same. @@ -259,13 +252,12 @@ where _commitments: impl IntoIterator>, point: &'a P::Point, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, _rng: Option<&mut dyn RngCore>, ) -> Result where P: 'a, - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, { let mut p = P::zero(); @@ -416,13 +408,12 @@ where commitments: impl IntoIterator>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Self::Error> where P: 'a, - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, { Marlin::::open_combinations( @@ -472,13 +463,11 @@ where commitments: impl IntoIterator>>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result>, Error> where P: 'a, - Self::Randomness: 'a, Self::CommitmentState: 'a, Self::Commitment: 'a, { @@ -508,7 +497,7 @@ where let mut proofs = Vec::new(); for (_point_label, (point, labels)) in query_to_labels_map.into_iter() { let mut query_polys: Vec<&'a LabeledPolynomial<_, _>> = Vec::new(); - let mut query_rands: Vec<&'a Self::Randomness> = Vec::new(); + let mut query_rands: Vec<&'a Self::CommitmentState> = Vec::new(); let mut query_comms: Vec<&'a LabeledCommitment> = Vec::new(); for label in labels { @@ -529,7 +518,6 @@ where query_comms, point, opening_challenges, - &vec![CommitmentState {}; query_rands.len()], query_rands, Some(rng), )?; diff --git a/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs b/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs index 8ccf300b..2e6b73cf 100644 --- a/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs +++ b/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs @@ -1,6 +1,6 @@ use crate::{BTreeMap, Vec}; use crate::{ - PCCommitterKey, PCPreparedVerifierKey, PCRandomness, PCUniversalParams, PCVerifierKey, + PCCommitmentState, PCCommitterKey, PCPreparedVerifierKey, PCUniversalParams, PCVerifierKey, }; use ark_ec::pairing::Pairing; use ark_poly::DenseMVPolynomial; @@ -362,7 +362,7 @@ where } } -impl PCRandomness for Randomness +impl PCCommitmentState for Randomness where E: Pairing, P: DenseMVPolynomial, diff --git a/poly-commit/src/marlin/marlin_pst13_pc/mod.rs b/poly-commit/src/marlin/marlin_pst13_pc/mod.rs index 2ab5d543..45265370 100644 --- a/poly-commit/src/marlin/marlin_pst13_pc/mod.rs +++ b/poly-commit/src/marlin/marlin_pst13_pc/mod.rs @@ -1,11 +1,11 @@ use crate::{ - kzg10::{self, CommitmentState}, + kzg10, marlin::{marlin_pc, Marlin}, CHALLENGE_SIZE, }; use crate::{BatchLCProof, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; -use crate::{PCRandomness, PCUniversalParams, PolynomialCommitment}; +use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment}; use crate::{ToString, Vec}; use ark_ec::AffineRepr; use ark_ec::{pairing::Pairing, scalar_mul::fixed_base::FixedBase, CurveGroup, VariableBaseMSM}; @@ -151,8 +151,7 @@ where type CommitterKey = CommitterKey; type VerifierKey = VerifierKey; type Commitment = marlin_pc::Commitment; - type CommitmentState = CommitmentState; - type Randomness = Randomness; + type CommitmentState = Randomness; type Proof = Proof; type BatchProof = Vec; type Error = Error; @@ -345,7 +344,6 @@ where ( Vec>, Vec, - Vec, ), Self::Error, > @@ -433,11 +431,7 @@ where end_timer!(commit_time); } end_timer!(commit_time); - Ok(( - commitments, - vec![CommitmentState {}; randomness.len()], - randomness, - )) + Ok((commitments, randomness)) } /// On input a polynomial `p` and a point `point`, outputs a proof for the same. @@ -447,13 +441,12 @@ where _commitments: impl IntoIterator>, point: &P::Point, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, _rng: Option<&mut dyn RngCore>, ) -> Result where P: 'a, - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, { // Compute random linear combinations of committed polynomials and randomness @@ -668,13 +661,12 @@ where commitments: impl IntoIterator>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Self::Error> where P: 'a, - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, { Marlin::::open_combinations( diff --git a/poly-commit/src/marlin/mod.rs b/poly-commit/src/marlin/mod.rs index 4f9e424e..1558486d 100644 --- a/poly-commit/src/marlin/mod.rs +++ b/poly-commit/src/marlin/mod.rs @@ -3,7 +3,7 @@ use crate::{kzg10, Error}; use crate::{BTreeMap, BTreeSet, Debug, RngCore, String, ToString, Vec}; use crate::{BatchLCProof, LabeledPolynomial, LinearCombination}; use crate::{Evaluations, LabeledCommitment, QuerySet}; -use crate::{PCRandomness, Polynomial, PolynomialCommitment}; +use crate::{PCCommitmentState, Polynomial, PolynomialCommitment}; use ark_crypto_primitives::sponge::CryptographicSponge; use ark_ec::pairing::Pairing; use ark_ec::AffineRepr; @@ -228,7 +228,7 @@ where commitments: impl IntoIterator>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Error> where @@ -241,7 +241,7 @@ where Commitment = marlin_pc::Commitment, Error = Error, >, - PC::Randomness: 'a + AddAssign<(E::ScalarField, &'a PC::Randomness)>, + PC::CommitmentState: 'a + AddAssign<(E::ScalarField, &'a PC::CommitmentState)>, PC::Commitment: 'a, { let label_map = polynomials @@ -262,7 +262,7 @@ where let mut degree_bound = None; let mut hiding_bound = None; - let mut randomness = PC::Randomness::empty(); + let mut randomness = PC::CommitmentState::empty(); let mut coeffs_and_comms = Vec::new(); let num_polys = lc.len(); @@ -309,7 +309,6 @@ where lc_commitments.iter(), &query_set, opening_challenges, - &vec![PC::CommitmentState::default(); lc_randomness.len()], lc_randomness.iter(), rng, )?; diff --git a/poly-commit/src/sonic_pc/mod.rs b/poly-commit/src/sonic_pc/mod.rs index a00fb5f3..e495463a 100644 --- a/poly-commit/src/sonic_pc/mod.rs +++ b/poly-commit/src/sonic_pc/mod.rs @@ -1,9 +1,8 @@ -use crate::kzg10::CommitmentState; use crate::{kzg10, PCCommitterKey, CHALLENGE_SIZE}; use crate::{BTreeMap, BTreeSet, String, ToString, Vec}; use crate::{BatchLCProof, DenseUVPolynomial, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; -use crate::{PCRandomness, PCUniversalParams, PolynomialCommitment}; +use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment}; use ark_ec::AffineRepr; use ark_ec::CurveGroup; @@ -147,8 +146,7 @@ where type CommitterKey = CommitterKey; type VerifierKey = VerifierKey; type Commitment = Commitment; - type CommitmentState = CommitmentState; - type Randomness = Randomness; + type CommitmentState = Randomness; type Proof = kzg10::Proof; type BatchProof = Vec; type Error = Error; @@ -284,7 +282,6 @@ where ( Vec>, Vec, - Vec, ), Self::Error, > @@ -294,7 +291,7 @@ where let rng = &mut crate::optional_rng::OptionalRng(rng); let commit_time = start_timer!(|| "Committing to polynomials"); let mut labeled_comms: Vec> = Vec::new(); - let mut randomness: Vec = Vec::new(); + let mut randomness: Vec = Vec::new(); for labeled_polynomial in polynomials { let enforced_degree_bounds: Option<&[usize]> = ck @@ -340,11 +337,7 @@ where } end_timer!(commit_time); - Ok(( - labeled_comms, - vec![CommitmentState {}; randomness.len()], - randomness, - )) + Ok((labeled_comms, randomness)) } fn open<'a>( @@ -353,12 +346,11 @@ where _commitments: impl IntoIterator>, point: &'a P::Point, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, _rng: Option<&mut dyn RngCore>, ) -> Result where - Self::Randomness: 'a, + Self::CommitmentState: 'a, Self::Commitment: 'a, P: 'a, { @@ -511,12 +503,10 @@ where commitments: impl IntoIterator>, query_set: &QuerySet, opening_challenges: &mut ChallengeGenerator, - _states: impl IntoIterator, - rands: impl IntoIterator, + rands: impl IntoIterator, rng: Option<&mut dyn RngCore>, ) -> Result, Self::Error> where - Self::Randomness: 'a, Self::CommitmentState: 'a, Self::Commitment: 'a, P: 'a, @@ -538,7 +528,7 @@ where let mut poly = P::zero(); let mut degree_bound = None; let mut hiding_bound = None; - let mut randomness = Self::Randomness::empty(); + let mut randomness = Self::CommitmentState::empty(); let mut comm = E::G1::zero(); let num_polys = lc.len(); @@ -592,7 +582,6 @@ where lc_commitments.iter(), &query_set, opening_challenges, - &vec![CommitmentState {}; lc_randomness.len()], lc_randomness.iter(), rng, )?;