zkcrypto / bls12_381

Implementation of the BLS12-381 pairing-friendly elliptic curve group
Other
304 stars 178 forks source link

Add API for computing pairings using cached information about G2 elements #15

Closed ebfull closed 5 years ago

ebfull commented 5 years ago

This is a standard optimization already present in most pairing libraries. Closes #9.

Instead of calling

pairing(&a, &b)

if b is fixed in advance, you can precompute b_prepared = G2Prepared::from(b) and instead compute

multi_miller_loop(&[(&a, &b_prepared)]).final_exponentiation()

and also, you can use this new multi_miller_loop API to compute the combination of many pairings like

multi_miller_loop(&[(&a, &b_prepared), (&c, &d_prepared)]).final_exponentiation()

and use the separate application of final_exponentiation() to perform batch equation checking while amortizing away the cost of applying the final exponentiation.