From 4455c2fff7ac742725b2aa9dd0689635c8c0dfe5 Mon Sep 17 00:00:00 2001 From: Chiro Hiro Date: Thu, 21 Sep 2023 08:38:32 +0700 Subject: [PATCH] Improve root calculation for KZG setup() (#211) * improve root calculation for KZG setup() * Update halo2_proofs/src/poly/kzg/commitment.rs Co-authored-by: Han * Fix rust format issue --------- Co-authored-by: Han --- halo2_proofs/src/poly/kzg/commitment.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/halo2_proofs/src/poly/kzg/commitment.rs b/halo2_proofs/src/poly/kzg/commitment.rs index 70050e824b..c9157f843d 100644 --- a/halo2_proofs/src/poly/kzg/commitment.rs +++ b/halo2_proofs/src/poly/kzg/commitment.rs @@ -88,11 +88,12 @@ where }; let mut g_lagrange_projective = vec![E::G1::identity(); n as usize]; - let mut root = E::Scalar::ROOT_OF_UNITY_INV.invert().unwrap(); + let mut root = E::Scalar::ROOT_OF_UNITY; for _ in k..E::Scalar::S { root = root.square(); } - let n_inv = Option::::from(E::Scalar::from(n).invert()) + let n_inv = E::Scalar::from(n) + .invert() .expect("inversion should be ok for n = 1< g_l, + None => g_to_lagrange(g.iter().map(PrimeCurveAffine::to_curve).collect(), k), }, g, g2,