Skip to content

Commit

Permalink
add a constructor (zcash#164)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Ethan-000 committed May 18, 2023
1 parent d374610 commit 468a752
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions halo2_proofs/src/poly/kzg/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<E::G1Affine>,
g_lagrange: Option<Vec<E::G1Affine>>,
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
Expand Down

0 comments on commit 468a752

Please sign in to comment.