From 468a7523a296a9792232953e9cfcb1f01eb82b40 Mon Sep 17 00:00:00 2001 From: Ethan-000 Date: Thu, 18 May 2023 16:49:53 +0100 Subject: [PATCH] add a constructor (#164) * add a constructor * add more comment * fix as review * remove clone * remove * no need to use new variable * change comment * fix clippy * rename to from_parts * remove n declaration --- halo2_proofs/src/poly/kzg/commitment.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/halo2_proofs/src/poly/kzg/commitment.rs b/halo2_proofs/src/poly/kzg/commitment.rs index a2886a016c..51f0c660d0 100644 --- a/halo2_proofs/src/poly/kzg/commitment.rs +++ b/halo2_proofs/src/poly/kzg/commitment.rs @@ -132,6 +132,30 @@ where } } + /// Initializes parameters for the curve through existing parameters + /// k, g, g_lagrange (optional), g2, s_g2 + pub fn from_parts( + &self, + k: u32, + g: Vec, + g_lagrange: Option>, + g2: E::G2Affine, + s_g2: E::G2Affine, + ) -> Self { + Self { + k, + n: 1 << k, + g_lagrange: if let Some(g_l) = g_lagrange { + g_l + } else { + g_to_lagrange(g.iter().map(PrimeCurveAffine::to_curve).collect(), k) + }, + g, + g2, + s_g2, + } + } + /// Returns gernerator on G2 pub fn g2(&self) -> E::G2Affine { self.g2