Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Updated Bn128PairingImpl to use optimized batch pairing #10765

Merged
merged 2 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ethcore/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down