Updated Bn128PairingImpl to use optimized batch pairing (#10765)

* Bn128PairingImpl uses pairing_batch method in bn

* updated Cargo.lock
This commit is contained in:
Seun LanLege
2019-06-20 22:16:11 +01:00
committed by David
parent 78d0a8696f
commit 213e007a4b
2 changed files with 5 additions and 3 deletions

View File

@@ -498,7 +498,7 @@ impl Impl for Bn128PairingImpl {
impl Bn128PairingImpl {
fn execute_with_error(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> {
use bn::{AffineG1, AffineG2, Fq, Fq2, pairing, G1, G2, Gt, Group};
use bn::{AffineG1, AffineG2, Fq, Fq2, pairing_batch, G1, G2, Gt, Group};
let elements = input.len() / 192; // (a, b_a, b_b - each 64-byte affine coordinates)
let ret_val = if input.len() == 0 {
@@ -539,7 +539,7 @@ impl Bn128PairingImpl {
vals.push((a, b));
};
let mul = vals.into_iter().fold(Gt::one(), |s, (a, b)| s * pairing(a, b));
let mul = pairing_batch(&vals);
if mul == Gt::one() {
U256::one()