Skip to content
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

Named algebras 2 (⚠️ breaking internals❗) #402

Merged
merged 11 commits into from
Jun 26, 2024
16 changes: 0 additions & 16 deletions PLANNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ Other tracks are stretch goals, contributions towards them are accepted.
- Endomorphism splitting bounds guarantee: i.e. division-based vs lattice-based splitting
- Fix optimized MSM

Internal API breakage, which might leak to others using internal APIs.

- Expand the library to support named fields and not just curves
- move and rename the config & constant folder
- use field instead of curve
- "named_math/fields_and_curves"
- matchingOrderBigInt -> BigInt[foo.getOrder()]
- Delete Mod*(), replace by fieldMod
- In the future there will likely be named ciphersuites or other high-level protocols



### Ethereum Consensus Track

- Implement cryptography and erasure codes EIP-7594 PeerDAS
Expand Down Expand Up @@ -130,10 +118,6 @@ Internal API breakage, which might leak to others using internal APIs.
- https://github.com/rust-lang/rust/pull/76986
- https://github.com/rust-lang/rfcs/pull/2884

- Shorter names:
- Rename to EC_ShortW
- Rename to EC_TwEdw

### Technical marketing track

- Create Python bindings
Expand Down
30 changes: 15 additions & 15 deletions benchmarks/bench_ec_g1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,34 @@ proc main() =
separator()
staticFor i, 0, AvailableCurves.len:
const curve = AvailableCurves[i]
addBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
addBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
addBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
addBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
addBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
addBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
separator()
affFromProjBench(ECP_ShortW_Prj[Fp[curve], G1], MulIters)
affFromJacBench(ECP_ShortW_Jac[Fp[curve], G1], MulIters)
affFromProjBench(EC_ShortW_Prj[Fp[curve], G1], MulIters)
affFromJacBench(EC_ShortW_Jac[Fp[curve], G1], MulIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromProjBatchBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
affFromProjBatchBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromProjBatchBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
affFromProjBatchBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromJacBatchBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
affFromJacBatchBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromJacBatchBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
affFromJacBatchBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
separator()

Expand Down
34 changes: 17 additions & 17 deletions benchmarks/bench_ec_g1_batch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@ proc main() =
separator()
staticFor i, 0, AvailableCurves.len:
const curve = AvailableCurves[i]
addBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_Prj[Fp[curve], G1], Iters)
addBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_Jac[Fp[curve], G1], Iters)
addBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
doublingBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
mixedAddBench(ECP_ShortW_JacExt[Fp[curve], G1], Iters)
addBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_Prj[Fp[curve], G1], Iters)
addBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_Jac[Fp[curve], G1], Iters)
addBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
doublingBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
mixedAddBench(EC_ShortW_JacExt[Fp[curve], G1], Iters)
separator()
# for numPoints in testNumPoints:
# let batchIters = max(1, Iters div numPoints)
# multiAddBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
# multiAddBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
# separator()
# for numPoints in testNumPoints:
# let batchIters = max(1, Iters div numPoints)
# multiAddBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
# multiAddBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
# separator()
# for numPoints in testNumPoints:
# let batchIters = max(1, Iters div numPoints)
# multiAddParallelBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, batchIters)
# multiAddParallelBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, batchIters)
# separator()
for numPoints in testNumPoints:
let batchIters = max(1, Iters div numPoints)
multiAddBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
multiAddBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
separator()
for numPoints in testNumPoints:
let batchIters = max(1, Iters div numPoints)
multiAddBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
multiAddBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
for numPoints in testNumPoints:
let batchIters = max(1, Iters div numPoints)
multiAddParallelBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, batchIters)
multiAddParallelBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, batchIters)
# separator()
# for numPoints in testNumPoints:
# let batchIters = max(1, Iters div numPoints)
# multiAddBench(ECP_ShortW_JacExt[Fp[curve], G1], numPoints, useBatching = false, batchIters)
# multiAddBench(EC_ShortW_JacExt[Fp[curve], G1], numPoints, useBatching = false, batchIters)
# separator()
# for numPoints in testNumPoints:
# let batchIters = max(1, Iters div numPoints)
# multiAddBench(ECP_ShortW_JacExt[Fp[curve], G1], numPoints, useBatching = true, batchIters)
# multiAddBench(EC_ShortW_JacExt[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
separator()

Expand Down
66 changes: 33 additions & 33 deletions benchmarks/bench_ec_g1_scalar_mul.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,45 @@ proc main() =
separator()
staticFor i, 0, AvailableCurves.len:
const curve = AvailableCurves[i]
const bits = curve.getCurveOrderBitwidth()
scalarMulVartimeDoubleAddBench(ECP_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulVartimeDoubleAddBench(ECP_ShortW_Jac[Fp[curve], G1], bits, MulIters)
const bits = Fr[curve].bits()
scalarMulVartimeDoubleAddBench(EC_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulVartimeDoubleAddBench(EC_ShortW_Jac[Fp[curve], G1], bits, MulIters)
separator()
scalarMulVartimeMinHammingWeightRecodingBench(ECP_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulVartimeMinHammingWeightRecodingBench(ECP_ShortW_Jac[Fp[curve], G1], bits, MulIters)
scalarMulVartimeMinHammingWeightRecodingBench(EC_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulVartimeMinHammingWeightRecodingBench(EC_ShortW_Jac[Fp[curve], G1], bits, MulIters)
separator()
scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulGenericBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulGenericBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulGenericBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulGenericBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulGenericBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulGenericBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulGenericBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulGenericBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
separator()
scalarMulVartimeWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
separator()
when bits >= 196: # All endomorphisms constants are below this threshold
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeEndoWNAFBench(ECP_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Prj[Fp[curve], G1], bits, window = 5, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 2, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 3, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 4, MulIters)
scalarMulVartimeEndoWNAFBench(EC_ShortW_Jac[Fp[curve], G1], bits, window = 5, MulIters)
separator()
scalarMulEndo( ECP_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulEndoWindow(ECP_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulEndo( ECP_ShortW_Jac[Fp[curve], G1], bits, MulIters)
scalarMulEndoWindow(ECP_ShortW_Jac[Fp[curve], G1], bits, MulIters)
scalarMulEndo( EC_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulEndoWindow(EC_ShortW_Prj[Fp[curve], G1], bits, MulIters)
scalarMulEndo( EC_ShortW_Jac[Fp[curve], G1], bits, MulIters)
scalarMulEndoWindow(EC_ShortW_Jac[Fp[curve], G1], bits, MulIters)
separator()
separator()

Expand Down
30 changes: 15 additions & 15 deletions benchmarks/bench_ec_g2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ proc main() =
separator()
staticFor i, 0, AvailableCurves.len:
const curve = AvailableCurves[i]
addBench(ECP_ShortW_Prj[Fp2[curve], G2], Iters)
addBench(ECP_ShortW_Jac[Fp2[curve], G2], Iters)
addBench(ECP_ShortW_JacExt[Fp2[curve], G2], Iters)
mixedAddBench(ECP_ShortW_Prj[Fp2[curve], G2], Iters)
mixedAddBench(ECP_ShortW_Jac[Fp2[curve], G2], Iters)
mixedAddBench(ECP_ShortW_JacExt[Fp2[curve], G2], Iters)
doublingBench(ECP_ShortW_Prj[Fp2[curve], G2], Iters)
doublingBench(ECP_ShortW_Jac[Fp2[curve], G2], Iters)
doublingBench(ECP_ShortW_JacExt[Fp2[curve], G2], Iters)
addBench(EC_ShortW_Prj[Fp2[curve], G2], Iters)
addBench(EC_ShortW_Jac[Fp2[curve], G2], Iters)
addBench(EC_ShortW_JacExt[Fp2[curve], G2], Iters)
mixedAddBench(EC_ShortW_Prj[Fp2[curve], G2], Iters)
mixedAddBench(EC_ShortW_Jac[Fp2[curve], G2], Iters)
mixedAddBench(EC_ShortW_JacExt[Fp2[curve], G2], Iters)
doublingBench(EC_ShortW_Prj[Fp2[curve], G2], Iters)
doublingBench(EC_ShortW_Jac[Fp2[curve], G2], Iters)
doublingBench(EC_ShortW_JacExt[Fp2[curve], G2], Iters)
separator()
affFromProjBench(ECP_ShortW_Prj[Fp2[curve], G2], MulIters)
affFromJacBench(ECP_ShortW_Jac[Fp2[curve], G2], MulIters)
affFromProjBench(EC_ShortW_Prj[Fp2[curve], G2], MulIters)
affFromJacBench(EC_ShortW_Jac[Fp2[curve], G2], MulIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromProjBatchBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
affFromProjBatchBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = false, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromProjBatchBench(ECP_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
affFromProjBatchBench(EC_ShortW_Prj[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromJacBatchBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
affFromJacBatchBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = false, batchIters)
separator()
for numPoints in [10, 100, 1000, 10000]:
let batchIters = max(1, Iters div numPoints)
affFromJacBatchBench(ECP_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
affFromJacBatchBench(EC_ShortW_Jac[Fp[curve], G1], numPoints, useBatching = true, batchIters)
separator()
separator()

Expand Down
Loading
Loading