Comments (2)
There are some approaches for modexp, modexp has the following signature:
fn modexp(base: BigInt, exp: BigInt, modulo: Int) -> BigInt
Montgomery
The issue with the Montgomery algorithm is that we need to precompute a constant
This is fine when we know
Problematic because we need to find a coprime, large number to an arbitrary
There are possible solutions to this though, if we split
- If
$n \equiv 1 \mod 2$ , we could simply choose$R = 2^{\log_{2}(n)+1}$ - If
$n \equiv 0 \mod 2$ , this is not really clear but Montgomery Reduction With Even Modulus proposes a solution using The Chinese Remainder Theorem but of course we would have to go and implement it.
Maybe there are more solutions with Montgomery but I have not found them.
Barret
An alternative to Montgomery's is the Barret Reduction.
Barret still needs to precompute 2 constants:
The election of
Also, as an advantage, the barret reduction does not need a special form like Montgomery's form
when operating.
The downside of this approach is that
Useful links:
- Montgomery arithmetic from a software perspective
- Montgomery reduction with even modulus
- Comparison of three modular reduction functions
- Algorithmica's chapter on Montgomery
from zksync_era_precompiles.
Closed as the research finished.
from zksync_era_precompiles.
Related Issues (20)
- Test ecmul failures HOT 2
- consecutive make clean/make failing (file erasure ?)
- Optimize `montgomerySub()`
- Inaccurate `t` value in `NAF_REPRESENTATIVE()` doc comment
- Potential G2 subgroup check optimization using NAF representation
- Wrong paper reference for `fp12CyclotomicSquare`
- Inacurate doc comment for `fp12Expt`
- Inaccurate `finalExponentiation` doc comment
- `g2ProjectiveFromAffine` does not have to make final check.
- Doc comments for functions
- Typo in referenced paper for `mixedAdditionStep` implementation
- NAF representation can be shortened
- Function `g2JacobianAdd` does not support same inputs
- No need to initialize `let l00, l01, l10, l11, l20, l21, l30, l31, l40, l41, l50, l51`
- `mixedAdditionStep` step is not necessary
- G1 point `-xp` and `-yp` can be precomputed before miller loop
- Simplify point-at-infinity check in G2 point addition
- Final exponentiation should only be applied to the accumulator
- `g2IsInSubGroup` can be optimised HOT 1
- G2 subgroup check is mandatory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zksync_era_precompiles.