This document lists the optimizations relevant to an elliptic curve or pairing-based cryptography library and whether Constantine has them implemented.
The optimizations can be of algebraic, algorithmic or "implementation details" nature. Using non-constant time code is always possible, it is listed if the speedup is significant.
## Big Integers
- Conditional copy
- [x] Loop unrolling
- [x] x86: Conditional Mov
- [x] x86: Full Assembly implementation
- [ ] SIMD instructions
- Add/Sub
- [x] int128
- [x] add-with-carry, sub-with-borrow intrinsics
- [x] loop unrolling
- [x] x86: Full Assembly implementation
- Multiplication
- [x] int128
- [x] loop unrolling
- [x] Comba multiplication / product Scanning
- [ ] Karatsuba
- [ ] Karatsuba + Comba
- [x] x86: Full Assembly implementation
- [x] x86: MULX, ADCX, ADOX instructions
- [x] Fused Multiply + Shift-right by word (for Barrett Reduction and approximating multiplication by fractional constant)
- Squaring
- [ ] Dedicated squaring functions
- [ ] int128
- [ ] loop unrolling
- [ ] x86: Full Assembly implementation
- [ ] x86: MULX, ADCX, ADOX instructions
## Finite Fields & Modular Arithmetic
- Representation
- [x] Montgomery Representation
- [ ] Barret Reduction
- [ ] Unsaturated Representation
- [ ] Mersenne Prime (2^k - 1),
- [ ] Generalized Mersenne Prime (NIST Prime P256: 2^256 - 2^224 + 2^192 + 2^96 - 1)
- [ ] Pseudo-Mersenne Prime (2^m - k for example Curve25519: 2^255 - 19)
- [ ] Golden Primes (φ^2 - φ - 1 with φ = 2^k for example Ed448-Goldilocks: 2^448 - 2^224 - 1)
- [ ] any prime modulus (lazy carry)
- Montgomery Reduction
- [x] int128
- [x] loop unrolling
- [x] x86: Full Assembly implementation
- [x] x86: MULX, ADCX, ADOX instructions
- Addition/substraction
- [x] int128
- [x] add-with-carry, sub-with-borrow intrinsics
- [x] loop unrolling
- [x] x86: Full Assembly implementation
- [x] Addition-chain for small constants
- Montgomery Multiplication
- [x] Fused multiply + reduce
- [x] int128
- [x] loop unrolling
- [x] x86: Full Assembly implementation
- [x] x86: MULX, ADCX, ADOX instructions
- [x] no-carry optimization for CIOS (Coarsely Integrated Operand Scanning)