-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: emulated BLS12-381 pairing #591
Conversation
Following #594, the last commit uses torus-based arithmetic for the entire final exp. This removes |
To finish this PR, here is the total number of constraints for an emulated bls12-381 pairing over bn254 scalar field: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I only made the double method on E6 public to be consistent with other methods.
Following #566, this PR implements an emulated BLS12-381 pairing circuit. It costs
3177374 = ~3.1M
R1CS constraints when verified in a BN254 Groth16. The gap between BN254 pairing (3.1M-2M=1.1M
) is justified by BLS12-381 size (emulating a 381-bit field in a 254-bit compared to 254-bit in 254-bit).The PR needs Consensys/gnark-crypto#360 for testing.
TODOs:
loopCounter[i]=1
, multiply lines between them (Mul014By014
) before multiplying by the accumulator (MulBy01245
). This is less efficient than 2 multiplications of lines by accumulator (MulBy014
) becauseMulBy01245
costs one more multiplication compared toMulBy01234
in the case of a D-type twist (e.g. BN254).We implement SQR2345 variant of Karabina's cyclotomic square which is the most circuit-efficient for a series of 4+ squares. However, inExpt()
here, there is a shift of size 3 which is optimal with SQR12345 variant (paragraph 5.6).(we don't use Karabina nor Granger-Scott cyclotomic square anymore. All the final exp is done with T2 arithmetic.)