mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-09 07:21:29 +01:00
Fix BLS12 G2PreparedGadget's AllocVar with a divisive twist (#77)
* fix * tidy up Cargo; add changelog * fix nostd * removal of the test * fmt
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
- [\#77](https://github.com/arkworks-rs/r1cs-std/pull/77) Fix BLS12 `G2PreparedGadget`'s `AllocVar` when G2 uses a divisive twist.
|
||||||
|
|
||||||
## v0.3.1
|
## v0.3.1
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use crate::{
|
|||||||
groups::curves::short_weierstrass::*,
|
groups::curves::short_weierstrass::*,
|
||||||
Vec,
|
Vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
/// Represents a projective point in G1.
|
/// Represents a projective point in G1.
|
||||||
@@ -124,16 +123,32 @@ impl<P: Bls12Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
|
|||||||
let cs = ns.cs();
|
let cs = ns.cs();
|
||||||
let g2_prep = f().map(|b| {
|
let g2_prep = f().map(|b| {
|
||||||
let projective_coeffs = &b.borrow().ell_coeffs;
|
let projective_coeffs = &b.borrow().ell_coeffs;
|
||||||
let mut z_s = projective_coeffs
|
match P::TWIST_TYPE {
|
||||||
.iter()
|
TwistType::M => {
|
||||||
.map(|(_, _, z)| *z)
|
let mut z_s = projective_coeffs
|
||||||
.collect::<Vec<_>>();
|
.iter()
|
||||||
ark_ff::fields::batch_inversion(&mut z_s);
|
.map(|(_, _, z)| *z)
|
||||||
projective_coeffs
|
.collect::<Vec<_>>();
|
||||||
.iter()
|
ark_ff::fields::batch_inversion(&mut z_s);
|
||||||
.zip(z_s)
|
projective_coeffs
|
||||||
.map(|((x, y, _), z_inv)| (*x * &z_inv, *y * &z_inv))
|
.iter()
|
||||||
.collect::<Vec<_>>()
|
.zip(z_s)
|
||||||
|
.map(|((x, y, _), z_inv)| (*x * &z_inv, *y * &z_inv))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
TwistType::D => {
|
||||||
|
let mut z_s = projective_coeffs
|
||||||
|
.iter()
|
||||||
|
.map(|(z, _, _)| *z)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
ark_ff::fields::batch_inversion(&mut z_s);
|
||||||
|
projective_coeffs
|
||||||
|
.iter()
|
||||||
|
.zip(z_s)
|
||||||
|
.map(|((_, x, y), z_inv)| (*x * &z_inv, *y * &z_inv))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let l = Vec::new_variable(
|
let l = Vec::new_variable(
|
||||||
|
|||||||
Reference in New Issue
Block a user