arkworks-rs / snark

Interfaces for Relations and SNARKs for these relations
https://www.arkworks.rs
Apache License 2.0
776 stars 209 forks source link

Implement BW6-761 curve #210

Closed yelhousni closed 4 years ago

yelhousni commented 4 years ago

152.

This PR implements BW6-761 curve from [HG20]. Type: Enhancement Label: Ready to review Priority: Medium

Motivation

Substitute the outer curve SW6 curve by the much faster curve BW6-761.

Description

This PR implements the fields and groups instantiation of the curve (and its twist) and an optimal ate pairing in [ABLR13] projective coordinates with a sextic M-twist (G2 over Fq, 2 small Miller loops (Alg.5) and a lattice-based optimized final exp (Alg.6)).

Followups:

There are few optimizations to do further:

Pratyush commented 4 years ago

Thanks for the awesome PR @yelhousni! Quick question: I see that the BW6Engine and BW6Parameters are defined in algebra-core and not in algebra. Is this because it works for any curve in the BW6 family?

yelhousni commented 4 years ago

@Pratyush LGTM, suggested changes are applied. BW6Engine is in algebra-core because indeed it works for any Brezing-Weng family of embedding degree k=6. As an example, the branches youssef/BW6-761-Fq-*-*-D use a D-twist with different curve parameters.

yelhousni commented 4 years ago

Actually, the 2-NAF method is only faster for the second ML because the hamming weight of the first ML in binary is the same as in 2-NAF. With this additional optimization, we reach a speedup of 32X for a Miller loop compared to SW6 and thus ~23.5X for a Groth16 proof verification.

Pratyush commented 4 years ago

@yelhousni this looks great to me! do you want to merge now, or do you want to implement the other optimizations that you mentiond above?

yelhousni commented 4 years ago

@Pratyush Let's merge now and later we can add the other optimizations.

Pratyush commented 4 years ago

Great!