From 6fc6d7ca018f3899b030618cb18580249b1e7c82 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Fri, 24 Nov 2023 18:26:20 +0700 Subject: [PATCH] Publish necessary properties for external use of KZG commitment (#232) * Publish properties of `ProverQuery` and `VerifierQuery` to external * Add method to create new instance of `ProverQuery` and `VerifierQuery` * Limit the accessibilities of `VerifierQuery` and `ProverQuery`'s fields * Add derive copy in `ProverQuery` and `VerifierQuery` --- halo2_proofs/src/poly/query.rs | 51 ++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/halo2_proofs/src/poly/query.rs b/halo2_proofs/src/poly/query.rs index b9894edd38..bc7a20c240 100644 --- a/halo2_proofs/src/poly/query.rs +++ b/halo2_proofs/src/poly/query.rs @@ -17,16 +17,30 @@ 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 + /// Point at which polynomial is queried pub(crate) point: C::Scalar, - /// coefficients of polynomial + /// Coefficients of polynomial pub(crate) poly: &'com Polynomial, - /// blinding factor of polynomial + /// Blinding factor of polynomial pub(crate) 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> { @@ -79,22 +93,31 @@ impl<'com, C: CurveAffine, M: MSM> VerifierQuery<'com, C, M> { } /// A polynomial query at a point -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct VerifierQuery<'com, C: CurveAffine, M: MSM> { - /// point at which polynomial is queried + /// Point at which polynomial is queried pub(crate) point: C::Scalar, - /// commitment to polynomial + /// Commitment to polynomial pub(crate) commitment: CommitmentReference<'com, C, M>, - /// evaluation of polynomial at query point + /// Evaluation of polynomial at query point pub(crate) eval: C::Scalar, } -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, +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, } } }