From 4d11a0a03a1c8a2686fa213b9e33144238861a20 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Sat, 18 Nov 2023 10:15:08 +0300 Subject: [PATCH 1/4] Publish properties of `ProverQuery` and `VerifierQuery` to external --- halo2_proofs/src/poly/query.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/halo2_proofs/src/poly/query.rs b/halo2_proofs/src/poly/query.rs index b9894edd38..5034652de2 100644 --- a/halo2_proofs/src/poly/query.rs +++ b/halo2_proofs/src/poly/query.rs @@ -19,12 +19,12 @@ pub trait Query: Sized + Clone + Send + Sync { /// A polynomial query at a point #[derive(Debug, Clone)] pub struct ProverQuery<'com, C: CurveAffine> { - /// point at which polynomial is queried - pub(crate) point: C::Scalar, - /// coefficients of polynomial - pub(crate) poly: &'com Polynomial, - /// blinding factor of polynomial - pub(crate) blind: Blind, + /// Point at which polynomial is queried + pub point: C::Scalar, + /// Coefficients of polynomial + pub poly: &'com Polynomial, + /// Blinding factor of polynomial + pub blind: Blind, } #[doc(hidden)] @@ -81,12 +81,12 @@ impl<'com, C: CurveAffine, M: MSM> VerifierQuery<'com, C, M> { /// A polynomial query at a point #[derive(Debug)] pub struct VerifierQuery<'com, C: CurveAffine, M: MSM> { - /// point at which polynomial is queried - pub(crate) point: C::Scalar, - /// commitment to polynomial - pub(crate) commitment: CommitmentReference<'com, C, M>, - /// evaluation of polynomial at query point - pub(crate) eval: C::Scalar, + /// Point at which polynomial is queried + pub point: C::Scalar, + /// Commitment to polynomial + pub commitment: CommitmentReference<'com, C, M>, + /// Evaluation of polynomial at query point + pub eval: C::Scalar, } impl<'com, C: CurveAffine, M: MSM> Clone for VerifierQuery<'com, C, M> { From 47fe617527ec159eef3f9f13a8f24f0e6982e5fd Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Sat, 18 Nov 2023 10:31:52 +0300 Subject: [PATCH 2/4] Add method to create new instance of `ProverQuery` and `VerifierQuery` --- halo2_proofs/src/poly/query.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/halo2_proofs/src/poly/query.rs b/halo2_proofs/src/poly/query.rs index 5034652de2..233dc84f23 100644 --- a/halo2_proofs/src/poly/query.rs +++ b/halo2_proofs/src/poly/query.rs @@ -27,6 +27,20 @@ pub struct ProverQuery<'com, C: CurveAffine> { pub blind: Blind, } +impl<'com, C> ProverQuery<'com, C> +where + C: CurveAffine, +{ + /// Create a new prover query based on a polynomial + pub fn new( + point: C::Scalar, + poly: &'com Polynomial, + blind: Blind, + ) -> Self { + ProverQuery { point, poly, blind } + } +} + #[doc(hidden)] #[derive(Copy, Clone)] pub struct PolynomialPointer<'com, C: CurveAffine> { @@ -89,6 +103,25 @@ pub struct VerifierQuery<'com, C: CurveAffine, M: MSM> { pub eval: C::Scalar, } +impl<'com, C, M> VerifierQuery<'com, C, M> +where + C: CurveAffine, + M: MSM, +{ + /// Create a new verifier query based on a commitment + pub fn new( + point: C::Scalar, + commitment: CommitmentReference<'com, C, M>, + eval: C::Scalar, + ) -> Self { + VerifierQuery { + point, + commitment, + eval, + } + } +} + impl<'com, C: CurveAffine, M: MSM> Clone for VerifierQuery<'com, C, M> { fn clone(&self) -> Self { Self { From 7d8035113d5bd24cef482aeb7874b5994dd742a0 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 23 Nov 2023 16:41:55 +0700 Subject: [PATCH 3/4] Limit the accessibilities of `VerifierQuery` and `ProverQuery`'s fields --- halo2_proofs/src/poly/query.rs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/halo2_proofs/src/poly/query.rs b/halo2_proofs/src/poly/query.rs index 233dc84f23..79f02934ff 100644 --- a/halo2_proofs/src/poly/query.rs +++ b/halo2_proofs/src/poly/query.rs @@ -20,11 +20,11 @@ pub trait Query: Sized + Clone + Send + Sync { #[derive(Debug, Clone)] pub struct ProverQuery<'com, C: CurveAffine> { /// Point at which polynomial is queried - pub point: C::Scalar, + pub(crate) point: C::Scalar, /// Coefficients of polynomial - pub poly: &'com Polynomial, + pub(crate) poly: &'com Polynomial, /// Blinding factor of polynomial - pub blind: Blind, + pub(crate) blind: Blind, } impl<'com, C> ProverQuery<'com, C> @@ -93,14 +93,14 @@ impl<'com, C: CurveAffine, M: MSM> VerifierQuery<'com, C, M> { } /// A polynomial query at a point -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct VerifierQuery<'com, C: CurveAffine, M: MSM> { /// Point at which polynomial is queried - pub point: C::Scalar, + pub(crate) point: C::Scalar, /// Commitment to polynomial - pub commitment: CommitmentReference<'com, C, M>, + pub(crate) commitment: CommitmentReference<'com, C, M>, /// Evaluation of polynomial at query point - pub eval: C::Scalar, + pub(crate) eval: C::Scalar, } impl<'com, C, M> VerifierQuery<'com, C, M> @@ -122,16 +122,6 @@ where } } -impl<'com, C: CurveAffine, M: MSM> Clone for VerifierQuery<'com, C, M> { - fn clone(&self) -> Self { - Self { - point: self.point, - commitment: self.commitment, - eval: self.eval, - } - } -} - #[allow(clippy::upper_case_acronyms)] #[derive(Clone, Debug)] pub enum CommitmentReference<'r, C: CurveAffine, M: MSM> { From 8270a67b0a847221a21bcd31b099462346674189 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Fri, 24 Nov 2023 11:10:17 +0700 Subject: [PATCH 4/4] Add derive copy in `ProverQuery` and `VerifierQuery` --- halo2_proofs/src/poly/query.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/halo2_proofs/src/poly/query.rs b/halo2_proofs/src/poly/query.rs index 79f02934ff..bc7a20c240 100644 --- a/halo2_proofs/src/poly/query.rs +++ b/halo2_proofs/src/poly/query.rs @@ -17,7 +17,7 @@ pub trait Query: Sized + Clone + Send + Sync { } /// A polynomial query at a point -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct ProverQuery<'com, C: CurveAffine> { /// Point at which polynomial is queried pub(crate) point: C::Scalar, @@ -93,7 +93,7 @@ impl<'com, C: CurveAffine, M: MSM> VerifierQuery<'com, C, M> { } /// A polynomial query at a point -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct VerifierQuery<'com, C: CurveAffine, M: MSM> { /// Point at which polynomial is queried pub(crate) point: C::Scalar,