-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
BN254-Snarks: bad performance on Fp4 squaring #154
Labels
Comments
mratsim
added a commit
that referenced
this issue
Feb 9, 2021
* consistent naming for dbl-width * Isolate double-width Fp2 mul * Implement double-width complex multiplication * Lay out Fp4 double-width mul * Off by p in square Fp4 as well :/ * less copies and stack space in addition chains * Address #154 partly * Fix #154, faster Fp4 square: less non-residue, no Mul, only square (bit more ops total) * Fix typo * better assembly scheduling for add/sub * Double-width -> Double-precision * Unred -> Unr * double-precision modular addition * Replace canUseNoCarryMontyMul and canUseNoCarryMontySquare by getSpareBits * Complete the double-precision implementation * Use double-precision path for Fp4 squaring and mul * remove mixin annotations * Lazy reduction in Fp4 prod * Fix assembly for sum2xMod * Assembly for double-precision negation * reduce white spaces in pairing benchmarks * ADX implies BMI2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason (multiplication by its super large 9+i non-residue?)
BN254-Snarks is very slow on Fp4
Suspect 1:
constantine/constantine/tower_field_extensions/tower_instantiation.nim
Lines 118 to 129 in c4a2dee
constantine/constantine/tower_field_extensions/tower_instantiation.nim
Lines 88 to 94 in 2c5e12d
Suspect 2:
The general squaring in quadratic field:
constantine/constantine/tower_field_extensions/extension_fields.nim
Lines 477 to 524 in c4a2dee
The basic expression is
(c0² + β c1², 2 c0 c1)
We can either minimize Mul/Squarings, requiring only 2 multiplications by rewriting to:
r0 = (c0 + c1)(c0 + β c1) - c0c1 - β c0c1
r1 = 2 c0c1
or only use squarings by rewritting to
r0 = a0² + β a1²
r1 = (a0 + a1)² - a0² - a1²
The first expression requires 2 multiplication by non-residue.
The text was updated successfully, but these errors were encountered: