Updated Bn128PairingImpl to use optimized batch pairing (#10765)
* Bn128PairingImpl uses pairing_batch method in bn * updated Cargo.lock
This commit is contained in:
parent
78d0a8696f
commit
213e007a4b
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -264,11 +264,13 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "bn"
|
||||
version = "0.4.4"
|
||||
source = "git+https://github.com/paritytech/bn#2a71dbde5ca93451c8da2135767896a64483759e"
|
||||
source = "git+https://github.com/paritytech/bn#6beba2ed6c9351622f9e948ccee4063846b2b39a"
|
||||
dependencies = [
|
||||
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user