Add ToConstraintFieldGadget for ProjectiveVar (#13)

This commit is contained in:
Weikeng Chen
2020-11-12 01:41:59 -08:00
committed by GitHub
parent 8dca325042
commit f4691621ee
14 changed files with 52 additions and 32 deletions

View File

@@ -31,8 +31,8 @@ impl<P: Bls12Parameters> PairingVar<P> {
let mut c1 = coeffs.1.clone();
let c2 = Fp2V::<P>::new(p.y.clone(), zero);
c1.c0 = c1.c0 * &p.x;
c1.c1 = c1.c1 * &p.x;
c1.c0 *= &p.x;
c1.c1 *= &p.x;
*f = f.mul_by_014(&c0, &c1, &c2)?;
Ok(())
}
@@ -41,8 +41,8 @@ impl<P: Bls12Parameters> PairingVar<P> {
let mut c1 = coeffs.0.clone();
let c2 = coeffs.1.clone();
c1.c0 = c1.c0 * &p.x;
c1.c1 = c1.c1 * &p.x;
c1.c0 *= &p.x;
c1.c1 *= &p.x;
*f = f.mul_by_034(&c0, &c1, &c2)?;
Ok(())
}

View File

@@ -101,14 +101,15 @@ impl<P: MNT4Parameters> PairingVar<P> {
let mut f = Fp4G::<P>::one();
let mut dbl_idx: usize = 0;
let mut add_idx: usize = 0;
// code below gets executed for all bits (EXCEPT the MSB itself) of
// mnt6_param_p (skipping leading zeros) in MSB to LSB order
for bit in BitIteratorBE::without_leading_zeros(P::ATE_LOOP_COUNT).skip(1) {
for (dbl_idx, bit) in BitIteratorBE::without_leading_zeros(P::ATE_LOOP_COUNT)
.skip(1)
.enumerate()
{
let dc = &q.double_coefficients[dbl_idx];
dbl_idx += 1;
let g_rr_at_p = Fp4G::<P>::new(
&dc.c_l - &dc.c_4c - &dc.c_j * &p.x_twist,

View File

@@ -96,14 +96,15 @@ impl<P: MNT6Parameters> PairingVar<P> {
let mut f = Fp6G::<P>::one();
let mut dbl_idx: usize = 0;
let mut add_idx: usize = 0;
// code below gets executed for all bits (EXCEPT the MSB itself) of
// mnt6_param_p (skipping leading zeros) in MSB to LSB order
for bit in BitIteratorBE::without_leading_zeros(P::ATE_LOOP_COUNT).skip(1) {
for (dbl_idx, bit) in BitIteratorBE::without_leading_zeros(P::ATE_LOOP_COUNT)
.skip(1)
.enumerate()
{
let dc = &q.double_coefficients[dbl_idx];
dbl_idx += 1;
let g_rr_at_p = Fp6Var::new(
&dc.c_l - &dc.c_4c - &dc.c_j * &p.x_twist,