From 5710a961a10051fa87bf7984e1ab5c9c50493a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mamy=20Andr=C3=A9-Ratsimbazafy?= Date: Sat, 6 Feb 2021 16:29:53 +0100 Subject: [PATCH] Rename ECP_ShortW_Proj -> ECP_ShortW_Prj --- README.md | 22 ++++---- benchmarks/bench_ec_g1.nim | 22 ++++---- benchmarks/bench_ec_g2.nim | 20 +++---- benchmarks/bench_elliptic_template.nim | 2 +- benchmarks/bench_pairing_template.nim | 34 +++++------ .../ec_shortweierstrass_projective.nim | 52 ++++++++--------- constantine/hash_to_curve/cofactors.nim | 16 +++--- constantine/io/io_ec.nim | 8 +-- constantine/pairing/lines_projective.nim | 12 ++-- constantine/pairing/pairing_bls12.nim | 10 ++-- constantine/pairing/pairing_bn.nim | 10 ++-- helpers/prng_unsafe.nim | 24 ++++---- metering/README.md | 4 +- metering/m_pairings.nim | 4 +- tests/t_ec_frobenius.nim | 56 +++++++++---------- tests/t_ec_sage_bls12_377.nim | 4 +- tests/t_ec_sage_bls12_381.nim | 4 +- tests/t_ec_sage_bn254_nogami.nim | 4 +- tests/t_ec_sage_bn254_snarks.nim | 4 +- tests/t_ec_sage_bw6_761_g1.nim | 4 +- tests/t_ec_sage_bw6_761_g2.nim | 4 +- tests/t_ec_sage_template.nim | 4 +- tests/t_ec_shortw_prj_edge_cases.nim | 8 +-- tests/t_ec_shortw_prj_g1_add_double.nim | 8 +-- tests/t_ec_shortw_prj_g1_mixed_add.nim | 8 +-- tests/t_ec_shortw_prj_g1_mul_distri.nim | 8 +-- tests/t_ec_shortw_prj_g1_mul_sanity.nim | 12 ++-- tests/t_ec_shortw_prj_g1_mul_vs_ref.nim | 8 +-- ..._ec_shortw_prj_g2_add_double_bls12_377.nim | 2 +- ..._ec_shortw_prj_g2_add_double_bls12_381.nim | 2 +- ..._shortw_prj_g2_add_double_bn254_snarks.nim | 2 +- .../t_ec_shortw_prj_g2_add_double_bw6_761.nim | 2 +- ...t_ec_shortw_prj_g2_mixed_add_bls12_377.nim | 2 +- ...t_ec_shortw_prj_g2_mixed_add_bls12_381.nim | 2 +- ...c_shortw_prj_g2_mixed_add_bn254_snarks.nim | 2 +- .../t_ec_shortw_prj_g2_mixed_add_bw6_761.nim | 2 +- ..._ec_shortw_prj_g2_mul_distri_bls12_377.nim | 2 +- ..._ec_shortw_prj_g2_mul_distri_bls12_381.nim | 2 +- ..._shortw_prj_g2_mul_distri_bn254_snarks.nim | 2 +- .../t_ec_shortw_prj_g2_mul_distri_bw6_761.nim | 2 +- ..._ec_shortw_prj_g2_mul_sanity_bls12_377.nim | 6 +- ..._ec_shortw_prj_g2_mul_sanity_bls12_381.nim | 6 +- ..._shortw_prj_g2_mul_sanity_bn254_snarks.nim | 6 +- .../t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim | 2 +- ..._ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim | 2 +- ..._ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim | 2 +- ..._shortw_prj_g2_mul_vs_ref_bn254_snarks.nim | 2 +- .../t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim | 2 +- tests/t_ec_template.nim | 2 +- tests/t_pairing_bls12_377_line_functions.nim | 8 +-- tests/t_pairing_bls12_381_line_functions.nim | 8 +-- tests/t_pairing_template.nim | 4 +- 52 files changed, 225 insertions(+), 225 deletions(-) diff --git a/README.md b/README.md index c4c176f..8ca7645 100644 --- a/README.md +++ b/README.md @@ -201,29 +201,29 @@ Pairing BLS12 BLS12_381 ``` --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EC Add G1 ECP_ShortW_Proj[Fp[BLS12_381]] 2118644.068 ops/s 472 ns/op 1416 CPU cycles (approx) +EC Add G1 ECP_ShortW_Prj[Fp[BLS12_381]] 2118644.068 ops/s 472 ns/op 1416 CPU cycles (approx) EC Add G1 ECP_ShortW_Jac[Fp[BLS12_381]] 1818181.818 ops/s 550 ns/op 1652 CPU cycles (approx) -EC Mixed Addition G1 ECP_ShortW_Proj[Fp[BLS12_381]] 2427184.466 ops/s 412 ns/op 1236 CPU cycles (approx) -EC Double G1 ECP_ShortW_Proj[Fp[BLS12_381]] 3460207.612 ops/s 289 ns/op 867 CPU cycles (approx) +EC Mixed Addition G1 ECP_ShortW_Prj[Fp[BLS12_381]] 2427184.466 ops/s 412 ns/op 1236 CPU cycles (approx) +EC Double G1 ECP_ShortW_Prj[Fp[BLS12_381]] 3460207.612 ops/s 289 ns/op 867 CPU cycles (approx) EC Double G1 ECP_ShortW_Jac[Fp[BLS12_381]] 3717472.119 ops/s 269 ns/op 809 CPU cycles (approx) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EC Projective to Affine G1 ECP_ShortW_Proj[Fp[BLS12_381]] 72020.166 ops/s 13885 ns/op 41656 CPU cycles (approx) +EC Projective to Affine G1 ECP_ShortW_Prj[Fp[BLS12_381]] 72020.166 ops/s 13885 ns/op 41656 CPU cycles (approx) EC Jacobian to Affine G1 ECP_ShortW_Jac[Fp[BLS12_381]] 71989.058 ops/s 13891 ns/op 41673 CPU cycles (approx) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EC ScalarMul G1 (unsafe reference DoubleAdd) ECP_ShortW_Proj[Fp[BLS12_381]] 7260.266 ops/s 137736 ns/op 413213 CPU cycles (approx) +EC ScalarMul G1 (unsafe reference DoubleAdd) ECP_ShortW_Prj[Fp[BLS12_381]] 7260.266 ops/s 137736 ns/op 413213 CPU cycles (approx) EC ScalarMul G1 (unsafe reference DoubleAdd) ECP_ShortW_Jac[Fp[BLS12_381]] 7140.970 ops/s 140037 ns/op 420115 CPU cycles (approx) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EC ScalarMul Generic G1 (window = 2, scratchsize = 4) ECP_ShortW_Proj[Fp[BLS12_381]] 5036.946 ops/s 198533 ns/op 595606 CPU cycles (approx) -EC ScalarMul Generic G1 (window = 3, scratchsize = 8) ECP_ShortW_Proj[Fp[BLS12_381]] 7080.799 ops/s 141227 ns/op 423684 CPU cycles (approx) -EC ScalarMul Generic G1 (window = 4, scratchsize = 16) ECP_ShortW_Proj[Fp[BLS12_381]] 8062.631 ops/s 124029 ns/op 372091 CPU cycles (approx) -EC ScalarMul Generic G1 (window = 5, scratchsize = 32) ECP_ShortW_Proj[Fp[BLS12_381]] 8377.244 ops/s 119371 ns/op 358116 CPU cycles (approx) +EC ScalarMul Generic G1 (window = 2, scratchsize = 4) ECP_ShortW_Prj[Fp[BLS12_381]] 5036.946 ops/s 198533 ns/op 595606 CPU cycles (approx) +EC ScalarMul Generic G1 (window = 3, scratchsize = 8) ECP_ShortW_Prj[Fp[BLS12_381]] 7080.799 ops/s 141227 ns/op 423684 CPU cycles (approx) +EC ScalarMul Generic G1 (window = 4, scratchsize = 16) ECP_ShortW_Prj[Fp[BLS12_381]] 8062.631 ops/s 124029 ns/op 372091 CPU cycles (approx) +EC ScalarMul Generic G1 (window = 5, scratchsize = 32) ECP_ShortW_Prj[Fp[BLS12_381]] 8377.244 ops/s 119371 ns/op 358116 CPU cycles (approx) EC ScalarMul Generic G1 (window = 2, scratchsize = 4) ECP_ShortW_Jac[Fp[BLS12_381]] 4703.359 ops/s 212614 ns/op 637847 CPU cycles (approx) EC ScalarMul Generic G1 (window = 3, scratchsize = 8) ECP_ShortW_Jac[Fp[BLS12_381]] 6901.407 ops/s 144898 ns/op 434697 CPU cycles (approx) EC ScalarMul Generic G1 (window = 4, scratchsize = 16) ECP_ShortW_Jac[Fp[BLS12_381]] 8022.720 ops/s 124646 ns/op 373940 CPU cycles (approx) EC ScalarMul Generic G1 (window = 5, scratchsize = 32) ECP_ShortW_Jac[Fp[BLS12_381]] 8433.552 ops/s 118574 ns/op 355725 CPU cycles (approx) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EC ScalarMul G1 (endomorphism accelerated) ECP_ShortW_Proj[Fp[BLS12_381]] 9703.933 ops/s 103051 ns/op 309155 CPU cycles (approx) -EC ScalarMul Window-2 G1 (endomorphism accelerated) ECP_ShortW_Proj[Fp[BLS12_381]] 13160.839 ops/s 75983 ns/op 227950 CPU cycles (approx) +EC ScalarMul G1 (endomorphism accelerated) ECP_ShortW_Prj[Fp[BLS12_381]] 9703.933 ops/s 103051 ns/op 309155 CPU cycles (approx) +EC ScalarMul Window-2 G1 (endomorphism accelerated) ECP_ShortW_Prj[Fp[BLS12_381]] 13160.839 ops/s 75983 ns/op 227950 CPU cycles (approx) EC ScalarMul G1 (endomorphism accelerated) ECP_ShortW_Jac[Fp[BLS12_381]] 9064.868 ops/s 110316 ns/op 330951 CPU cycles (approx) EC ScalarMul Window-2 G1 (endomorphism accelerated) ECP_ShortW_Jac[Fp[BLS12_381]] 12722.484 ops/s 78601 ns/op 235806 CPU cycles (approx) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/benchmarks/bench_ec_g1.nim b/benchmarks/bench_ec_g1.nim index 54b962f..252a7b2 100644 --- a/benchmarks/bench_ec_g1.nim +++ b/benchmarks/bench_ec_g1.nim @@ -45,30 +45,30 @@ proc main() = separator() staticFor i, 0, AvailableCurves.len: const curve = AvailableCurves[i] - addBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], Iters) + addBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], Iters) addBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], Iters) - mixedAddBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], Iters) + mixedAddBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], Iters) mixedAddBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], Iters) - doublingBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], Iters) + doublingBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], Iters) doublingBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], Iters) separator() - affFromProjBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], MulIters) + affFromProjBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], MulIters) affFromJacBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], MulIters) separator() - scalarMulUnsafeDoubleAddBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], MulIters) + scalarMulUnsafeDoubleAddBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], MulIters) scalarMulUnsafeDoubleAddBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], MulIters) separator() - scalarMulGenericBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], window = 2, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], window = 3, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], window = 4, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp[curve], NotOnTwist], window = 5, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], window = 2, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], window = 3, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], window = 4, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp[curve], NotOnTwist], window = 5, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], window = 2, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], window = 3, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], window = 4, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp[curve], NotOnTwist], window = 5, MulIters) separator() - scalarMulEndo(ECP_ShortW_Proj[Fp[curve], NotOnTwist], MulIters) - scalarMulEndoWindow(ECP_ShortW_Proj[Fp[curve], NotOnTwist], MulIters) + scalarMulEndo(ECP_ShortW_Prj[Fp[curve], NotOnTwist], MulIters) + scalarMulEndoWindow(ECP_ShortW_Prj[Fp[curve], NotOnTwist], MulIters) scalarMulEndo(ECP_ShortW_Jac[Fp[curve], NotOnTwist], MulIters) scalarMulEndoWindow(ECP_ShortW_Jac[Fp[curve], NotOnTwist], MulIters) separator() diff --git a/benchmarks/bench_ec_g2.nim b/benchmarks/bench_ec_g2.nim index d737db5..929b2df 100644 --- a/benchmarks/bench_ec_g2.nim +++ b/benchmarks/bench_ec_g2.nim @@ -46,29 +46,29 @@ proc main() = separator() staticFor i, 0, AvailableCurves.len: const curve = AvailableCurves[i] - addBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], Iters) + addBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], Iters) addBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], Iters) - mixedAddBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], Iters) + mixedAddBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], Iters) mixedAddBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], Iters) - doublingBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], Iters) + doublingBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], Iters) doublingBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], Iters) separator() - affFromProjBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], MulIters) + affFromProjBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], MulIters) affFromJacBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], MulIters) separator() - scalarMulUnsafeDoubleAddBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], MulIters) + scalarMulUnsafeDoubleAddBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], MulIters) scalarMulUnsafeDoubleAddBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], MulIters) separator() - scalarMulGenericBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], window = 2, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], window = 3, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], window = 4, MulIters) - scalarMulGenericBench(ECP_ShortW_Proj[Fp2[curve], OnTwist], window = 5, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], window = 2, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], window = 3, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], window = 4, MulIters) + scalarMulGenericBench(ECP_ShortW_Prj[Fp2[curve], OnTwist], window = 5, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], window = 2, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], window = 3, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], window = 4, MulIters) scalarMulGenericBench(ECP_ShortW_Jac[Fp2[curve], OnTwist], window = 5, MulIters) separator() - scalarMulEndo(ECP_ShortW_Proj[Fp2[curve], OnTwist], MulIters) + scalarMulEndo(ECP_ShortW_Prj[Fp2[curve], OnTwist], MulIters) scalarMulEndo(ECP_ShortW_Jac[Fp2[curve], OnTwist], MulIters) separator() separator() diff --git a/benchmarks/bench_elliptic_template.nim b/benchmarks/bench_elliptic_template.nim index 6870855..9fef4ec 100644 --- a/benchmarks/bench_elliptic_template.nim +++ b/benchmarks/bench_elliptic_template.nim @@ -68,7 +68,7 @@ proc mixedAddBench*(T: typedesc, iters: int) = let P = rng.random_unsafe(T) let Q = rng.random_unsafe(T) var Qaff: ECP_ShortW_Aff[T.F, T.Tw] - when Q is ECP_ShortW_Proj: + when Q is ECP_ShortW_Prj: Qaff.affineFromProjective(Q) else: Qaff.affineFromJacobian(Q) diff --git a/benchmarks/bench_pairing_template.nim b/benchmarks/bench_pairing_template.nim index 50ad36e..c327c8b 100644 --- a/benchmarks/bench_pairing_template.nim +++ b/benchmarks/bench_pairing_template.nim @@ -52,8 +52,8 @@ func random_point*(rng: var RngState, EC: typedesc): EC {.noInit.} = proc lineDoubleBench*(C: static Curve, iters: int) = var line: Line[Fp2[C]] - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) - let P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) + let P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Paff.affineFromProjective(P) bench("Line double", C, iters): @@ -61,10 +61,10 @@ proc lineDoubleBench*(C: static Curve, iters: int) = proc lineAddBench*(C: static Curve, iters: int) = var line: Line[Fp2[C]] - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Qaff: ECP_ShortW_Aff[Fp2[C], OnTwist] @@ -75,8 +75,8 @@ proc lineAddBench*(C: static Curve, iters: int) = proc mulFp12byLine_xyz000_Bench*(C: static Curve, iters: int) = var line: Line[Fp2[C]] - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) - let P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) + let P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Paff.affineFromProjective(P) @@ -88,8 +88,8 @@ proc mulFp12byLine_xyz000_Bench*(C: static Curve, iters: int) = proc mulFp12byLine_xy000z_Bench*(C: static Curve, iters: int) = var line: Line[Fp2[C]] - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) - let P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) + let P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Paff.affineFromProjective(P) @@ -101,8 +101,8 @@ proc mulFp12byLine_xy000z_Bench*(C: static Curve, iters: int) = proc millerLoopBLS12Bench*(C: static Curve, iters: int) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Qaff: ECP_ShortW_Aff[Fp2[C], OnTwist] @@ -116,8 +116,8 @@ proc millerLoopBLS12Bench*(C: static Curve, iters: int) = proc millerLoopBNBench*(C: static Curve, iters: int) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var Paff: ECP_ShortW_Aff[Fp[C], NotOnTwist] Qaff: ECP_ShortW_Aff[Fp2[C], OnTwist] @@ -160,8 +160,8 @@ proc finalExpBNBench*(C: static Curve, iters: int) = proc pairingBLS12Bench*(C: static Curve, iters: int) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var f: Fp12[C] @@ -170,8 +170,8 @@ proc pairingBLS12Bench*(C: static Curve, iters: int) = proc pairingBNBench*(C: static Curve, iters: int) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var f: Fp12[C] diff --git a/constantine/elliptic/ec_shortweierstrass_projective.nim b/constantine/elliptic/ec_shortweierstrass_projective.nim index c45d3e8..1d79df6 100644 --- a/constantine/elliptic/ec_shortweierstrass_projective.nim +++ b/constantine/elliptic/ec_shortweierstrass_projective.nim @@ -22,7 +22,7 @@ export Twisted # # ############################################################ -type ECP_ShortW_Proj*[F; Tw: static Twisted] = object +type ECP_ShortW_Prj*[F; Tw: static Twisted] = object ## Elliptic curve point for a curve in Short Weierstrass form ## y² = x³ + a x + b ## @@ -34,11 +34,11 @@ type ECP_ShortW_Proj*[F; Tw: static Twisted] = object ## Note that projective coordinates are not unique x*, y*, z*: F -func `==`*(P, Q: ECP_ShortW_Proj): SecretBool = +func `==`*(P, Q: ECP_ShortW_Prj): SecretBool = ## Constant-time equality check ## This is a costly operation # Reminder: the representation is not unique - type F = ECP_ShortW_Proj.F + type F = ECP_ShortW_Prj.F var a{.noInit.}, b{.noInit.}: F @@ -50,7 +50,7 @@ func `==`*(P, Q: ECP_ShortW_Proj): SecretBool = b.prod(Q.y, P.z) result = result and a == b -func isInf*(P: ECP_ShortW_Proj): SecretBool = +func isInf*(P: ECP_ShortW_Prj): SecretBool = ## Returns true if P is an infinity point ## and false otherwise ## @@ -60,13 +60,13 @@ func isInf*(P: ECP_ShortW_Proj): SecretBool = ## Y can be anything result = P.x.isZero() and P.z.isZero() -func setInf*(P: var ECP_ShortW_Proj) = +func setInf*(P: var ECP_ShortW_Prj) = ## Set ``P`` to infinity P.x.setZero() P.y.setOne() P.z.setZero() -func ccopy*(P: var ECP_ShortW_Proj, Q: ECP_ShortW_Proj, ctl: SecretBool) = +func ccopy*(P: var ECP_ShortW_Prj, Q: ECP_ShortW_Prj, ctl: SecretBool) = ## Constant-time conditional copy ## If ctl is true: Q is copied into P ## if ctl is false: Q is not copied and P is unmodified @@ -75,7 +75,7 @@ func ccopy*(P: var ECP_ShortW_Proj, Q: ECP_ShortW_Proj, ctl: SecretBool) = ccopy(fP, fQ, ctl) func trySetFromCoordsXandZ*[F; Tw]( - P: var ECP_ShortW_Proj[F, Tw], + P: var ECP_ShortW_Prj[F, Tw], x, z: F): SecretBool = ## Try to create a point the elliptic curve ## Y²Z = X³ + aXZ² + bZ³ (projective coordinates) @@ -93,7 +93,7 @@ func trySetFromCoordsXandZ*[F; Tw]( P.z = z func trySetFromCoordX*[F; Tw]( - P: var ECP_ShortW_Proj[F, Tw], + P: var ECP_ShortW_Prj[F, Tw], x: F): SecretBool = ## Try to create a point the elliptic curve ## y² = x³ + a x + b (affine coordinate) @@ -110,24 +110,24 @@ func trySetFromCoordX*[F; Tw]( P.x = x P.z.setOne() -func neg*(P: var ECP_ShortW_Proj, Q: ECP_ShortW_Proj) = +func neg*(P: var ECP_ShortW_Prj, Q: ECP_ShortW_Prj) = ## Negate ``P`` P.x = Q.x P.y.neg(Q.y) P.z = Q.z -func neg*(P: var ECP_ShortW_Proj) = +func neg*(P: var ECP_ShortW_Prj) = ## Negate ``P`` P.y.neg() -func cneg*(P: var ECP_ShortW_Proj, ctl: CTBool) = +func cneg*(P: var ECP_ShortW_Prj, ctl: CTBool) = ## Conditional negation. ## Negate if ``ctl`` is true P.y.cneg(ctl) func sum*[F; Tw: static Twisted]( - r: var ECP_ShortW_Proj[F, Tw], - P, Q: ECP_ShortW_Proj[F, Tw] + r: var ECP_ShortW_Prj[F, Tw], + P, Q: ECP_ShortW_Prj[F, Tw] ) = ## Elliptic curve point addition for Short Weierstrass curves in projective coordinates ## @@ -225,8 +225,8 @@ func sum*[F; Tw: static Twisted]( {.error: "Not implemented.".} func madd*[F; Tw: static Twisted]( - r: var ECP_ShortW_Proj[F, Tw], - P: ECP_ShortW_Proj[F, Tw], + r: var ECP_ShortW_Prj[F, Tw], + P: ECP_ShortW_Prj[F, Tw], Q: ECP_ShortW_Aff[F, Tw] ) = ## Elliptic curve mixed addition for Short Weierstrass curves @@ -288,8 +288,8 @@ func madd*[F; Tw: static Twisted]( {.error: "Not implemented.".} func double*[F; Tw: static Twisted]( - r: var ECP_ShortW_Proj[F, Tw], - P: ECP_ShortW_Proj[F, Tw] + r: var ECP_ShortW_Prj[F, Tw], + P: ECP_ShortW_Prj[F, Tw] ) = ## Elliptic curve point doubling for Short Weierstrass curves in projective coordinate ## @@ -361,25 +361,25 @@ func double*[F; Tw: static Twisted]( else: {.error: "Not implemented.".} -func `+=`*(P: var ECP_ShortW_Proj, Q: ECP_ShortW_Proj) = +func `+=`*(P: var ECP_ShortW_Prj, Q: ECP_ShortW_Prj) = ## In-place point addition # TODO test for aliasing support - var tmp {.noInit.}: ECP_ShortW_Proj + var tmp {.noInit.}: ECP_ShortW_Prj tmp.sum(P, Q) P = tmp -func `+=`*(P: var ECP_ShortW_Proj, Q: ECP_ShortW_Aff) = +func `+=`*(P: var ECP_ShortW_Prj, Q: ECP_ShortW_Aff) = ## In-place mixed point addition # used in line_addition P.madd(P, Q) -func double*(P: var ECP_ShortW_Proj) = - var tmp {.noInit.}: ECP_ShortW_Proj +func double*(P: var ECP_ShortW_Prj) = + var tmp {.noInit.}: ECP_ShortW_Prj tmp.double(P) P = tmp -func diff*(r: var ECP_ShortW_Proj, - P, Q: ECP_ShortW_Proj +func diff*(r: var ECP_ShortW_Prj, + P, Q: ECP_ShortW_Prj ) = ## r = P - Q ## Can handle r and Q aliasing @@ -389,7 +389,7 @@ func diff*(r: var ECP_ShortW_Proj, func affineFromProjective*[F, Tw]( aff: var ECP_ShortW_Aff[F, Tw], - proj: ECP_ShortW_Proj[F, Tw]) = + proj: ECP_ShortW_Prj[F, Tw]) = var invZ {.noInit.}: F invZ.inv(proj.z) @@ -397,7 +397,7 @@ func affineFromProjective*[F, Tw]( aff.y.prod(proj.y, invZ) func projectiveFromAffine*[F, Tw]( - proj: var ECP_ShortW_Proj[F, Tw], + proj: var ECP_ShortW_Prj[F, Tw], aff: ECP_ShortW_Aff[F, Tw]) {.inline.} = proj.x = aff.x proj.y = aff.y diff --git a/constantine/hash_to_curve/cofactors.nim b/constantine/hash_to_curve/cofactors.nim index a6e7a94..cdf5965 100644 --- a/constantine/hash_to_curve/cofactors.nim +++ b/constantine/hash_to_curve/cofactors.nim @@ -42,40 +42,40 @@ const Cofactor_Eff_BLS12_381_G1 = BigInt[64].fromHex"0xd201000000010001" const Cofactor_Eff_BLS12_381_G2 = BigInt[636].fromHex"0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551" ## P -> (x^2 - x - 1) P + (x - 1) psi(P) + psi(psi(2P)) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp[BN254_Nogami], NotOnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp[BN254_Nogami], NotOnTwist]) {.inline.} = ## Clear the cofactor of BN254_Nogami G1 ## BN curve have a G1 cofactor of 1 so this is a no-op discard -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp2[BN254_Nogami], OnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp2[BN254_Nogami], OnTwist]) {.inline.} = ## Clear the cofactor of BN254_Snarks G2 # Endomorphism acceleration cannot be used if cofactor is not cleared P.scalarMulGeneric(Cofactor_Eff_BN254_Nogami_G2) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist]) {.inline.} = ## Clear the cofactor of BN254_Snarks G1 ## BN curve have a G1 cofactor of 1 so this is a no-op discard -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist]) {.inline.} = ## Clear the cofactor of BN254_Snarks G2 # Endomorphism acceleration cannot be used if cofactor is not cleared P.scalarMulGeneric(Cofactor_Eff_BN254_Snarks_G2) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist]) {.inline.} = ## Clear the cofactor of BLS12_377 G1 P.scalarMulGeneric(Cofactor_Eff_BLS12_377_G1) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist]) {.inline.} = ## Clear the cofactor of BLS12_377 G2 # Endomorphism acceleration cannot be used if cofactor is not cleared P.scalarMulGeneric(Cofactor_Eff_BLS12_377_G2) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist]) {.inline.} = ## Clear the cofactor of BLS12_381 G1 P.scalarMulGeneric(Cofactor_Eff_BLS12_381_G1) -func clearCofactorReference*(P: var ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist]) {.inline.} = +func clearCofactorReference*(P: var ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist]) {.inline.} = ## Clear the cofactor of BLS12_381 G2 # Endomorphism acceleration cannot be used if cofactor is not cleared P.scalarMulGeneric(Cofactor_Eff_BLS12_381_G2) diff --git a/constantine/io/io_ec.nim b/constantine/io/io_ec.nim index 73b4370..e662efb 100644 --- a/constantine/io/io_ec.nim +++ b/constantine/io/io_ec.nim @@ -26,7 +26,7 @@ import # # ############################################################ -func toHex*[EC: ECP_ShortW_Proj or ECP_ShortW_Jac or ECP_ShortW_Aff](P: EC): string = +func toHex*[EC: ECP_ShortW_Prj or ECP_ShortW_Jac or ECP_ShortW_Aff](P: EC): string = ## Stringify an elliptic curve point to Hex ## Note. Leading zeros are not removed. ## Result is prefixed with 0x @@ -39,7 +39,7 @@ func toHex*[EC: ECP_ShortW_Proj or ECP_ShortW_Jac or ECP_ShortW_Aff](P: EC): str ## This proc output may change format in the future var aff {.noInit.}: ECP_ShortW_Aff[EC.F, EC.Tw] - when EC is ECP_ShortW_Proj: + when EC is ECP_ShortW_Prj: aff.affineFromProjective(P) elif EC is ECP_ShortW_Jac: aff.affineFromJacobian(P) @@ -52,7 +52,7 @@ func toHex*[EC: ECP_ShortW_Proj or ECP_ShortW_Jac or ECP_ShortW_Aff](P: EC): str result.appendHex(aff.y, bigEndian) result &= "\n)" -func fromHex*(dst: var (ECP_ShortW_Proj or ECP_ShortW_Jac), x, y: string): bool {.raises: [ValueError].}= +func fromHex*(dst: var (ECP_ShortW_Prj or ECP_ShortW_Jac), x, y: string): bool {.raises: [ValueError].}= ## Convert hex strings to a G1 curve point ## Returns `false` ## if there is no point with coordinates (`x`, `y`) on the curve @@ -63,7 +63,7 @@ func fromHex*(dst: var (ECP_ShortW_Proj or ECP_ShortW_Jac), x, y: string): bool dst.z.setOne() return bool(isOnCurve(dst.x, dst.y, dst.Tw)) -func fromHex*(dst: var (ECP_ShortW_Proj or ECP_ShortW_Jac), x0, x1, y0, y1: string): bool {.raises: [ValueError].}= +func fromHex*(dst: var (ECP_ShortW_Prj or ECP_ShortW_Jac), x0, x1, y0, y1: string): bool {.raises: [ValueError].}= ## Convert hex strings to a G2 curve point ## Returns `false` ## if there is no point with coordinates (`x`, `y`) on the curve diff --git a/constantine/pairing/lines_projective.nim b/constantine/pairing/lines_projective.nim index e9790c8..80f4783 100644 --- a/constantine/pairing/lines_projective.nim +++ b/constantine/pairing/lines_projective.nim @@ -46,7 +46,7 @@ export lines_common func line_eval_double[F]( line: var Line[F], - T: ECP_ShortW_Proj[F, OnTwist]) = + T: ECP_ShortW_Prj[F, OnTwist]) = ## Evaluate the line function for doubling ## i.e. the tangent at T ## @@ -116,7 +116,7 @@ func line_eval_double[F]( func line_eval_add[F]( line: var Line[F], - T: ECP_ShortW_Proj[F, OnTwist], + T: ECP_ShortW_Prj[F, OnTwist], Q: ECP_ShortW_Aff[F, OnTwist]) = ## Evaluate the line function for addition ## i.e. the line between T and Q @@ -160,7 +160,7 @@ func line_eval_add[F]( func line_eval_fused_double[F]( line: var Line[F], - T: var ECP_ShortW_Proj[F, OnTwist]) = + T: var ECP_ShortW_Prj[F, OnTwist]) = ## Fused line evaluation and elliptic point doubling # Grewal et al, 2012 adapted to Scott 2019 line notation var A {.noInit.}, B {.noInit.}, C {.noInit.}: F @@ -227,7 +227,7 @@ func line_eval_fused_double[F]( func line_eval_fused_add[F]( line: var Line[F], - T: var ECP_ShortW_Proj[F, OnTwist], + T: var ECP_ShortW_Prj[F, OnTwist], Q: ECP_ShortW_Aff[F, OnTwist]) = ## Fused line evaluation and elliptic point addition # Grewal et al, 2012 adapted to Scott 2019 line notation @@ -283,7 +283,7 @@ func line_eval_fused_add[F]( func line_double*[F1, F2]( line: var Line[F2], - T: var ECP_ShortW_Proj[F2, OnTwist], + T: var ECP_ShortW_Prj[F2, OnTwist], P: ECP_ShortW_Aff[F1, NotOnTwist]) = ## Doubling step of the Miller loop ## T in G2, P in G1 @@ -300,7 +300,7 @@ func line_double*[F1, F2]( func line_add*[F1, F2]( line: var Line[F2], - T: var ECP_ShortW_Proj[F2, OnTwist], + T: var ECP_ShortW_Prj[F2, OnTwist], Q: ECP_ShortW_Aff[F2, OnTwist], P: ECP_ShortW_Aff[F1, NotOnTwist]) = ## Addition step of the Miller loop diff --git a/constantine/pairing/pairing_bls12.nim b/constantine/pairing/pairing_bls12.nim index 23f53ff..079243a 100644 --- a/constantine/pairing/pairing_bls12.nim +++ b/constantine/pairing/pairing_bls12.nim @@ -80,7 +80,7 @@ func millerLoopGenericBLS12*[C]( # or we ensure the loop is done for a number of iterations strictly less # than the curve order which is the case for BLS12 curves var - T {.noInit.}: ECP_ShortW_Proj[Fp2[C], OnTwist] + T {.noInit.}: ECP_ShortW_Prj[Fp2[C], OnTwist] line {.noInit.}: Line[Fp2[C]] nQ{.noInit.}: typeof(Q) @@ -117,8 +117,8 @@ func finalExpGeneric[C: static Curve](f: var Fp12[C]) = func pairing_bls12_reference*[C]( gt: var Fp12[C], - P: ECP_ShortW_Proj[Fp[C], NotOnTwist], - Q: ECP_ShortW_Proj[Fp2[C], OnTwist]) = + P: ECP_ShortW_Prj[Fp[C], NotOnTwist], + Q: ECP_ShortW_Prj[Fp2[C], OnTwist]) = ## Compute the optimal Ate Pairing for BLS12 curves ## Input: P ∈ G1, Q ∈ G2 ## Output: e(P, Q) ∈ Gt @@ -191,8 +191,8 @@ func finalExpHard_BLS12*[C](f: var Fp12[C]) {.meter.} = func pairing_bls12*[C]( gt: var Fp12[C], - P: ECP_ShortW_Proj[Fp[C], NotOnTwist], - Q: ECP_ShortW_Proj[Fp2[C], OnTwist]) {.meter.} = + P: ECP_ShortW_Prj[Fp[C], NotOnTwist], + Q: ECP_ShortW_Prj[Fp2[C], OnTwist]) {.meter.} = ## Compute the optimal Ate Pairing for BLS12 curves ## Input: P ∈ G1, Q ∈ G2 ## Output: e(P, Q) ∈ Gt diff --git a/constantine/pairing/pairing_bn.nim b/constantine/pairing/pairing_bn.nim index e0a6eeb..49bef54 100644 --- a/constantine/pairing/pairing_bn.nim +++ b/constantine/pairing/pairing_bn.nim @@ -78,7 +78,7 @@ func millerLoopGenericBN*[C]( # than the curve order which is the case for BN curves var - T {.noInit.}: ECP_ShortW_Proj[Fp2[C], OnTwist] + T {.noInit.}: ECP_ShortW_Prj[Fp2[C], OnTwist] line {.noInit.}: Line[Fp2[C]] nQ{.noInit.}: typeof(Q) @@ -128,8 +128,8 @@ func finalExpGeneric[C: static Curve](f: var Fp12[C]) = func pairing_bn_reference*[C]( gt: var Fp12[C], - P: ECP_ShortW_Proj[Fp[C], NotOnTwist], - Q: ECP_ShortW_Proj[Fp2[C], OnTwist]) = + P: ECP_ShortW_Prj[Fp[C], NotOnTwist], + Q: ECP_ShortW_Prj[Fp2[C], OnTwist]) = ## Compute the optimal Ate Pairing for BN curves ## Input: P ∈ G1, Q ∈ G2 ## Output: e(P, Q) ∈ Gt @@ -199,8 +199,8 @@ func finalExpHard_BN*[C: static Curve](f: var Fp12[C]) = func pairing_bn*[C]( gt: var Fp12[C], - P: ECP_ShortW_Proj[Fp[C], NotOnTwist], - Q: ECP_ShortW_Proj[Fp2[C], OnTwist]) = + P: ECP_ShortW_Prj[Fp[C], NotOnTwist], + Q: ECP_ShortW_Prj[Fp2[C], OnTwist]) = ## Compute the optimal Ate Pairing for BLS12 curves ## Input: P ∈ G1, Q ∈ G2 ## Output: e(P, Q) ∈ Gt diff --git a/helpers/prng_unsafe.nim b/helpers/prng_unsafe.nim index 4845957..e43a9e5 100644 --- a/helpers/prng_unsafe.nim +++ b/helpers/prng_unsafe.nim @@ -233,7 +233,7 @@ func random_long01Seq(rng: var RngState, a: var ExtensionField) = # Elliptic curves # ------------------------------------------------------------ -func random_unsafe(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = +func random_unsafe(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate == 1 ## Unsafe: for testing and benchmarking purposes only var fieldElem {.noInit.}: a.F @@ -245,7 +245,7 @@ func random_unsafe(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Aff rng.random_unsafe(fieldElem) success = trySetFromCoordX(a, fieldElem) -func random_unsafe_with_randZ(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Jac)) = +func random_unsafe_with_randZ(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate being random ## Unsafe: for testing and benchmarking purposes only var Z{.noInit.}: a.F @@ -258,7 +258,7 @@ func random_unsafe_with_randZ(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ rng.random_unsafe(fieldElem) success = trySetFromCoordsXandZ(a, fieldElem, Z) -func random_highHammingWeight(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = +func random_highHammingWeight(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate == 1 ## This will be generated with a biaised RNG with high Hamming Weight ## to trigger carry bugs @@ -271,7 +271,7 @@ func random_highHammingWeight(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ rng.random_highHammingWeight(fieldElem) success = trySetFromCoordX(a, fieldElem) -func random_highHammingWeight_with_randZ(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Jac)) = +func random_highHammingWeight_with_randZ(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate == 1 ## This will be generated with a biaised RNG with high Hamming Weight ## to trigger carry bugs @@ -285,7 +285,7 @@ func random_highHammingWeight_with_randZ(rng: var RngState, a: var (ECP_ShortW_P rng.random_highHammingWeight(fieldElem) success = trySetFromCoordsXandZ(a, fieldElem, Z) -func random_long01Seq(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = +func random_long01Seq(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate == 1 ## This will be generated with a biaised RNG ## that produces long bitstrings of 0 and 1 @@ -299,7 +299,7 @@ func random_long01Seq(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_A rng.random_long01Seq(fieldElem) success = trySetFromCoordX(a, fieldElem) -func random_long01Seq_with_randZ(rng: var RngState, a: var (ECP_ShortW_Proj or ECP_ShortW_Jac)) = +func random_long01Seq_with_randZ(rng: var RngState, a: var (ECP_ShortW_Prj or ECP_ShortW_Jac)) = ## Initialize a random curve point with Z coordinate == 1 ## This will be generated with a biaised RNG ## that produces long bitstrings of 0 and 1 @@ -320,7 +320,7 @@ func random_long01Seq_with_randZ(rng: var RngState, a: var (ECP_ShortW_Proj or E func random_unsafe*(rng: var RngState, T: typedesc): T = ## Create a random Field or Extension Field or Curve Element ## Unsafe: for testing and benchmarking purposes only - when T is (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac): + when T is (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac): rng.random_unsafe(result) elif T is SomeNumber: cast[T](rng.next()) # TODO: Rely on casting integer actually converting in C (i.e. uint64->uint32 is valid) @@ -329,7 +329,7 @@ func random_unsafe*(rng: var RngState, T: typedesc): T = else: # Fields rng.random_unsafe(result) -func random_unsafe_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Proj or ECP_ShortW_Jac]): T = +func random_unsafe_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Prj or ECP_ShortW_Jac]): T = ## Create a random curve element with a random Z coordinate ## Unsafe: for testing and benchmarking purposes only rng.random_unsafe_with_randZ(result) @@ -337,7 +337,7 @@ func random_unsafe_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Proj or func random_highHammingWeight*(rng: var RngState, T: typedesc): T = ## Create a random Field or Extension Field or Curve Element ## Skewed towards high Hamming Weight - when T is (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac): + when T is (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac): rng.random_highHammingWeight(result) elif T is SomeNumber: cast[T](rng.next()) # TODO: Rely on casting integer actually converting in C (i.e. uint64->uint32 is valid) @@ -346,7 +346,7 @@ func random_highHammingWeight*(rng: var RngState, T: typedesc): T = else: # Fields rng.random_highHammingWeight(result) -func random_highHammingWeight_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Proj or ECP_ShortW_Jac]): T = +func random_highHammingWeight_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Prj or ECP_ShortW_Jac]): T = ## Create a random curve element with a random Z coordinate ## Skewed towards high Hamming Weight rng.random_highHammingWeight_with_randZ(result) @@ -354,7 +354,7 @@ func random_highHammingWeight_with_randZ*(rng: var RngState, T: typedesc[ECP_Sho func random_long01Seq*(rng: var RngState, T: typedesc): T = ## Create a random Field or Extension Field or Curve Element ## Skewed towards long bitstrings of 0 or 1 - when T is (ECP_ShortW_Proj or ECP_ShortW_Aff or ECP_ShortW_Jac): + when T is (ECP_ShortW_Prj or ECP_ShortW_Aff or ECP_ShortW_Jac): rng.random_long01Seq(result) elif T is SomeNumber: cast[T](rng.next()) # TODO: Rely on casting integer actually converting in C (i.e. uint64->uint32 is valid) @@ -363,7 +363,7 @@ func random_long01Seq*(rng: var RngState, T: typedesc): T = else: # Fields rng.random_long01Seq(result) -func random_long01Seq_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Proj or ECP_ShortW_Jac]): T = +func random_long01Seq_with_randZ*(rng: var RngState, T: typedesc[ECP_ShortW_Prj or ECP_ShortW_Jac]): T = ## Create a random curve element with a random Z coordinate ## Skewed towards long bitstrings of 0 or 1 rng.random_long01Seq_with_randZ(result) diff --git a/metering/README.md b/metering/README.md index 7456289..f31efbd 100644 --- a/metering/README.md +++ b/metering/README.md @@ -34,8 +34,8 @@ func random_point*(rng: var RngState, EC: typedesc): EC {.noInit.} = proc pairingBLS12Meter*(C: static Curve) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var f: Fp12[C] diff --git a/metering/m_pairings.nim b/metering/m_pairings.nim index 3803f73..25aae65 100644 --- a/metering/m_pairings.nim +++ b/metering/m_pairings.nim @@ -28,8 +28,8 @@ func random_point*(rng: var RngState, EC: typedesc): EC {.noInit.} = proc pairingBLS12Meter*(C: static Curve) = let - P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist]) - Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist]) + P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist]) + Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist]) var f: Fp12[C] diff --git a/tests/t_ec_frobenius.nim b/tests/t_ec_frobenius.nim index 33e46df..ff50f75 100644 --- a/tests/t_ec_frobenius.nim +++ b/tests/t_ec_frobenius.nim @@ -30,7 +30,7 @@ echo "frobenius xoshiro512** seed: ", seed proc test( id: int, - EC: typedesc[ECP_ShortW_Proj], + EC: typedesc[ECP_ShortW_Prj], Px0, Px1, Py0, Py1: string, Qx0, Qx1, Qy0, Qy1: string ) = @@ -55,7 +55,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" # - sage sage/frobenius_bls12_381.sage test( id = 0, - EC = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Px0 = "598e4c8c14c24c90834f2debedee4db3d31fed98a5134177704bfec14f46cb5", Px1 = "c6fffa61daeb7caaf96983e70f164931d958c6820b205cdde19f2fa1eaaa7b1", Py0 = "2f5fa252a27df56f5ca2e9c3382c17e531d317d50396f3fe952704304946a5a", @@ -68,7 +68,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 1, - EC = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Px0 = "21014830dd88a0e7961e704cea531200866c5df46cb25aa3e2aac8d4fec64c6e", Px1 = "1db17d8364def10443beab6e4a055c210d3e49c7c3af31e9cfb66d829938dca7", Py0 = "1394ab8c346ad3eba14fa14789d3bbfc2deed5a7a510da8e9418580515d27bda", @@ -81,7 +81,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 2, - EC = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Px0 = "46f2a2be9a3e19c1bb484fc37703ff64c3d7379de22249ccf0881037948beec", Px1 = "10a5aaae14cb028f4ff4b81d41b712038b9f620a99e208c23504887e56831806", Py0 = "2e6c3ebe0f3dada0063dc59f85fe2264dc3502bf65206336106a8d39d838a7b2", @@ -94,7 +94,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 3, - EC = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Px0 = "1cf3af1d41e89d8df378aa81463a978c021f27f4a48387e74655ce2cf5c1f298", Px1 = "36553e80e5c7c7360c7a2ae6bf1b8f68eb48804fc7eba7d2f56f09e87bbb0b1", Py0 = "25f03e551d74b6be3268bf001905dfbe0bcbe43a2d1aac645a3ca8650b52e551", @@ -109,7 +109,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 0, - EC = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Px0 = "112de13b7cd42bccdb005f2d4dc2726f360243103335ef6cf5e217e777554ae7c1deff5ddb5bcbb581fc9f13728a439", Px1 = "10d1a8963e5c6854d5e610ece9914f9b5619c27652be1e9ec3e87687d63ed5d45b449bf59c2481e18ac6159f75966ac", Py0 = "8aaf3a8660cf0edd6e97a2cd7837af1c63ec89e18f9bf4c64638662a661636b928a4f8097e6a2e8dfa11e13c51b075", @@ -122,7 +122,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 1, - EC = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Px0 = "2f9318360b53c2d706061f527571e91679e6086a72ce8203ba1a04850f83bb192b29307e9b2d63feb1d23979e3f632", Px1 = "3cbab0789968a3a35fa5d2e2326baa40c34d11a4af05a4109350944300ce32eef74dc5e47ba46717bd8bf87604696d", Py0 = "14ea84922f76f2681fec869dce26141392975dcdb4f21d5fa8aec06b37bf71ba6249c219ecbaef4a266196dafb4ad19", @@ -135,7 +135,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 2, - EC = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Px0 = "833ca23630be463c388ea6cfcff5b0e3b055065702a84310d2c726aee14d9e140cba05be79b5cb0441816d9e8c8370", Px1 = "264a9755524baac8d9e53b0a45789e9dafcb6b453e965061fcfa20bb12a27d9b9417d5277ae2a499b1cfe567d75e2d", Py0 = "5b670b9789825e2b48101b5b6e660cf9117e29c521dad54640cb356b674b3946c98cb43909c3495fb6d6d231891b7e", @@ -148,7 +148,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 3, - EC = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Px0 = "14cd89e2e2755ddc086f63fd62e1f9904c3c1497243455c578a963e81b389f04e95ceafc4f47dc777579cdc82eca79b", Px1 = "ba8801beba0654f20ccb78783efa7a911d182ec0eb99abe10f9a3d26b46fb7f90552e4ff6beb4df4611a9072be648b", Py0 = "12e23bc97d891f2a047bac9c90e728cb89760c812156f96c95e36c40f1c830cf6ecbb5d407b189070d48a92eb461ea6", @@ -163,7 +163,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 0, - EC = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Px0 = "d6904be428a0310dbd6e15a744a774bcf9800abe27536267a5383f1ddbd7783e1dc20098a8e045e3cca66b83f6d7f0f", Px1 = "12107f6ef71d0d1e3bcba9e00a0675d3080519dd1b6c086bd660eb2d2bca8f276e283a891b5c0615064d7886af625cf2", Py0 = "c592a3546d2d61d671070909e97860822db0a389e351c1744bdbb2c472cf52f3ca3e94068b0b6f3b0121923659131f5", @@ -176,7 +176,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 1, - EC = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Px0 = "112de130b7cd42bccdb005f2d4dc2726f360243103335ef6cf5e217e777554ae7c1deff5ddb5bcbb581fc9f13728a439", Px1 = "10d1a89a63e5c6854d5e610ece9914f9b5619c27652be1e9ec3e87687d63ed5d45b449bf59c2481e18ac6159f75966ac", Py0 = "11261c8fcb0f4f560479547fe6b2a1c1e8b648d87e54c39f299eba8729294e99b415851d134ca31e8bb861c42e6f1022", @@ -189,7 +189,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 2, - EC = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Px0 = "2f93183360b53c2d706061f527571e91679e6086a72ce8203ba1a04850f83bb192b29307e9b2d63feb1d23979e3f632", Px1 = "3cbab0c789968a3a35fa5d2e2326baa40c34d11a4af05a4109350944300ce32eef74dc5e47ba46717bd8bf87604696d", Py0 = "2b8d995b0f2114442b7bbdbe5732fbf94430d6d413e1f388031f3abb956e598cb6764275a75832c1670868c458378b6", @@ -202,7 +202,7 @@ suite "ψ (Psi) - Untwist-Frobenius-Twist Endomorphism on G2 vs SageMath" & " [" test( id = 3, - EC = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + EC = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Px0 = "d7d1c55ddf8bd03b7a15c3ea4f8f69aee37bf282d4aac82b7bd1fd47139250b9c708997a7ff8f603e48f0471c2cfe03", Px1 = "d145a91934a6ad865d24ab556ae1e6c42decdd05d676b80e53365a6ff7536332859c9682e7200e40515f675415d71a3", Py0 = "6de67fa12af93813a42612b1e9449c7b1f160c5de004ec26ea61010e48ba38dcf158d2692f347fdc6c6332bbec7106f", @@ -240,11 +240,11 @@ suite "ψ - psi(psi(P)) == psi2(P) - (Untwist-Frobenius-Twist Endomorphism)" & " test(EC, randZ = false, gen = Long01Sequence) test(EC, randZ = true, gen = Long01Sequence) - testAll(ECP_ShortW_Proj[Fp2[BN254_Nogami], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist]) - testAll(ECP_ShortW_Proj[Fp[BW6_761], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Nogami], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist]) + testAll(ECP_ShortW_Prj[Fp[BW6_761], OnTwist]) suite "ψ²(P) - [t]ψ(P) + [p]P = Inf" & " [" & $WordBitwidth & "-bit mode]": const Iters = 10 @@ -307,11 +307,11 @@ suite "ψ²(P) - [t]ψ(P) + [p]P = Inf" & " [" & $WordBitwidth & "-bit mode]": test(EC, randZ = false, gen = Long01Sequence) test(EC, randZ = true, gen = Long01Sequence) - testAll(ECP_ShortW_Proj[Fp2[BN254_Nogami], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist]) - testAll(ECP_ShortW_Proj[Fp[BW6_761], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Nogami], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist]) + testAll(ECP_ShortW_Prj[Fp[BW6_761], OnTwist]) suite "ψ⁴(P) - ψ²(P) + P = Inf (k-th cyclotomic polynomial with embedding degree k=12)" & " [" & $WordBitwidth & "-bit mode]": const Iters = 10 @@ -338,10 +338,10 @@ suite "ψ⁴(P) - ψ²(P) + P = Inf (k-th cyclotomic polynomial with embedding d test(EC, randZ = false, gen = Long01Sequence) test(EC, randZ = true, gen = Long01Sequence) - testAll(ECP_ShortW_Proj[Fp2[BN254_Nogami], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist]) - testAll(ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Nogami], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist]) + testAll(ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist]) suite "ψ²(P) - ψ(P) + P = Inf (k-th cyclotomic polynomial with embedding degree k=6)" & " [" & $WordBitwidth & "-bit mode]": const Iters = 10 @@ -368,4 +368,4 @@ suite "ψ²(P) - ψ(P) + P = Inf (k-th cyclotomic polynomial with embedding degr test(EC, randZ = false, gen = Long01Sequence) test(EC, randZ = true, gen = Long01Sequence) - testAll(ECP_ShortW_Proj[Fp[BW6_761], OnTwist]) + testAll(ECP_ShortW_Prj[Fp[BW6_761], OnTwist]) diff --git a/tests/t_ec_sage_bls12_377.nim b/tests/t_ec_sage_bls12_377.nim index 4b29493..af9ba48 100644 --- a/tests/t_ec_sage_bls12_377.nim +++ b/tests/t_ec_sage_bls12_377.nim @@ -16,7 +16,7 @@ import ./t_ec_sage_template run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], "t_ec_sage_bls12_377_g1_projective" ) @@ -26,7 +26,7 @@ run_scalar_mul_test_vs_sage( ) run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], "t_ec_sage_bls12_377_g2_projective" ) diff --git a/tests/t_ec_sage_bls12_381.nim b/tests/t_ec_sage_bls12_381.nim index 78b7fab..b1dd06c 100644 --- a/tests/t_ec_sage_bls12_381.nim +++ b/tests/t_ec_sage_bls12_381.nim @@ -16,7 +16,7 @@ import ./t_ec_sage_template run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], "t_ec_sage_bls12_381_g1_projective" ) @@ -26,7 +26,7 @@ run_scalar_mul_test_vs_sage( ) run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], "t_ec_sage_bls12_381_g2_projective" ) diff --git a/tests/t_ec_sage_bn254_nogami.nim b/tests/t_ec_sage_bn254_nogami.nim index 88a3e30..910502c 100644 --- a/tests/t_ec_sage_bn254_nogami.nim +++ b/tests/t_ec_sage_bn254_nogami.nim @@ -16,7 +16,7 @@ import ./t_ec_sage_template run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BN254_Nogami], NotOnTwist], + ECP_ShortW_Prj[Fp[BN254_Nogami], NotOnTwist], "t_ec_sage_bn254_nogami_g1_projective" ) @@ -26,7 +26,7 @@ run_scalar_mul_test_vs_sage( ) run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp2[BN254_Nogami], OnTwist], + ECP_ShortW_Prj[Fp2[BN254_Nogami], OnTwist], "t_ec_sage_bn254_nogami_g2_projective" ) diff --git a/tests/t_ec_sage_bn254_snarks.nim b/tests/t_ec_sage_bn254_snarks.nim index ce3fc89..a2277da 100644 --- a/tests/t_ec_sage_bn254_snarks.nim +++ b/tests/t_ec_sage_bn254_snarks.nim @@ -16,7 +16,7 @@ import ./t_ec_sage_template run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], "t_ec_sage_bn254_snarks_g1_projective" ) @@ -26,7 +26,7 @@ run_scalar_mul_test_vs_sage( ) run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], "t_ec_sage_bn254_snarks_g2_projective" ) diff --git a/tests/t_ec_sage_bw6_761_g1.nim b/tests/t_ec_sage_bw6_761_g1.nim index afc1550..3e455c7 100644 --- a/tests/t_ec_sage_bw6_761_g1.nim +++ b/tests/t_ec_sage_bw6_761_g1.nim @@ -21,7 +21,7 @@ import # TODO: upstream run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], "t_ec_sage_bw6_761_g1_projective" ) @@ -31,7 +31,7 @@ run_scalar_mul_test_vs_sage( ) # run_scalar_mul_test_vs_sage( -# ECP_ShortW_Proj[Fp[BW6_761], OnTwist], +# ECP_ShortW_Prj[Fp[BW6_761], OnTwist], # "t_ec_sage_bw6_761_g2_projective" # ) diff --git a/tests/t_ec_sage_bw6_761_g2.nim b/tests/t_ec_sage_bw6_761_g2.nim index 4cf2962..a15ad14 100644 --- a/tests/t_ec_sage_bw6_761_g2.nim +++ b/tests/t_ec_sage_bw6_761_g2.nim @@ -21,7 +21,7 @@ import # TODO: upstream # run_scalar_mul_test_vs_sage( -# ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], +# ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], # "t_ec_sage_bw6_761_g1_projective" # ) @@ -31,7 +31,7 @@ import # ) run_scalar_mul_test_vs_sage( - ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ECP_ShortW_Prj[Fp[BW6_761], OnTwist], "t_ec_sage_bw6_761_g2_projective" ) diff --git a/tests/t_ec_sage_template.nim b/tests/t_ec_sage_template.nim index 9611b6b..822474d 100644 --- a/tests/t_ec_sage_template.nim +++ b/tests/t_ec_sage_template.nim @@ -194,7 +194,7 @@ proc run_scalar_mul_test_vs_sage*( const G1_or_G2 = "G2" let vec = loadVectors(ScalarMulTestG2[ECP_ShortW_Aff[EC.F, EC.Tw]]) - const coord = when EC is ECP_ShortW_Proj: " Projective coordinates " + const coord = when EC is ECP_ShortW_Prj: " Projective coordinates " elif EC is ECP_ShortW_Jac: " Jacobian coordinates " const testSuiteDesc = "Scalar Multiplication " & $EC.F.C & " " & G1_or_G2 & " vs SageMath" @@ -209,7 +209,7 @@ proc run_scalar_mul_test_vs_sage*( reference {.noInit.}: EC endo {.noInit.}: EC - when EC is ECP_ShortW_Proj: + when EC is ECP_ShortW_Prj: P.projectiveFromAffine(vec.vectors[i].P) Q.projectiveFromAffine(vec.vectors[i].Q) else: diff --git a/tests/t_ec_shortw_prj_edge_cases.nim b/tests/t_ec_shortw_prj_edge_cases.nim index a172a9a..f15a722 100644 --- a/tests/t_ec_shortw_prj_edge_cases.nim +++ b/tests/t_ec_shortw_prj_edge_cases.nim @@ -26,7 +26,7 @@ import ./support/ec_reference_scalar_mult func testAddAssociativity[EC](a, b, c: EC) = - var tmp1{.noInit.}, tmp2{.noInit.}: ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist] + var tmp1{.noInit.}, tmp2{.noInit.}: ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist] # r0 = (a + b) + c tmp1.sum(a, b) @@ -63,7 +63,7 @@ func testAddAssociativity[EC](a, b, c: EC) = suite "Short Weierstrass Elliptic Curve - Edge cases [" & $WordBitwidth & "-bit mode]": test "EC Add G2 is associative - #60": - var a, b, c: ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist] + var a, b, c: ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist] var ax, az, bx, bz, cx, cz: Fp2[BLS12_381] ax.fromHex( @@ -101,7 +101,7 @@ suite "Short Weierstrass Elliptic Curve - Edge cases [" & $WordBitwidth & "-bit test "EC Add G2 is associative - #65-1": - var a, b, c: ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist] + var a, b, c: ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist] var ax, az, bx, bz, cx, cz: Fp2[BLS12_381] ax.fromHex( @@ -139,7 +139,7 @@ suite "Short Weierstrass Elliptic Curve - Edge cases [" & $WordBitwidth & "-bit test "EC Add G2 is associative - #65-2": - var a, b, c: ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist] + var a, b, c: ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist] var ax, az, bx, bz, cx, cz: Fp2[BLS12_381] ax.fromHex( diff --git a/tests/t_ec_shortw_prj_g1_add_double.nim b/tests/t_ec_shortw_prj_g1_add_double.nim index 67ccb89..69d52a7 100644 --- a/tests/t_ec_shortw_prj_g1_add_double.nim +++ b/tests/t_ec_shortw_prj_g1_add_double.nim @@ -17,25 +17,25 @@ const Iters = 1 run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g1_add_double_" & $BN254_Snarks ) run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g1_add_double_" & $BLS12_381 ) run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g1_add_double_" & $BLS12_377 ) run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g1_add_double_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g1_mixed_add.nim b/tests/t_ec_shortw_prj_g1_mixed_add.nim index 0aec6f1..ba34cc2 100644 --- a/tests/t_ec_shortw_prj_g1_mixed_add.nim +++ b/tests/t_ec_shortw_prj_g1_mixed_add.nim @@ -18,25 +18,25 @@ const Iters = 12 run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BN254_Snarks ) run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BLS12_381 ) run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BLS12_377 ) run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g1_mul_distri.nim b/tests/t_ec_shortw_prj_g1_mul_distri.nim index 82b01d1..04a9f77 100644 --- a/tests/t_ec_shortw_prj_g1_mul_distri.nim +++ b/tests/t_ec_shortw_prj_g1_mul_distri.nim @@ -18,25 +18,25 @@ const ItersMul = Iters div 4 run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_distributive_" & $BN254_Snarks ) run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_distributive_" & $BLS12_381 ) run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_distributive_" & $BLS12_377 ) run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_distributive_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g1_mul_sanity.nim b/tests/t_ec_shortw_prj_g1_mul_sanity.nim index ffbd2b4..fee19ee 100644 --- a/tests/t_ec_shortw_prj_g1_mul_sanity.nim +++ b/tests/t_ec_shortw_prj_g1_mul_sanity.nim @@ -24,7 +24,7 @@ const ItersMul = Iters div 4 run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_sanity_" & $BN254_Snarks ) @@ -56,8 +56,8 @@ suite "Order checks on BN254_Snarks": bool(impl.isInf()) bool(reference.isInf()) - test(ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = false) - test(ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = true) + test(ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = false) + test(ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = true) # TODO: BLS12 is using a subgroup of order "r" such as r*h = CurveOrder # with h the curve cofactor # instead of the full group @@ -74,19 +74,19 @@ suite "Order checks on BN254_Snarks": bool not ay.sqrt_if_square() run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_sanity_" & $BLS12_381 ) run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_sanity_" & $BLS12_377 ) run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_sanity_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g1_mul_vs_ref.nim b/tests/t_ec_shortw_prj_g1_mul_vs_ref.nim index 3e50618..2c732d3 100644 --- a/tests/t_ec_shortw_prj_g1_mul_vs_ref.nim +++ b/tests/t_ec_shortw_prj_g1_mul_vs_ref.nim @@ -18,25 +18,25 @@ const ItersMul = Iters div 4 run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp[BN254_Snarks], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BN254_Snarks], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_vs_ref_" & $BN254_Snarks ) run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp[BLS12_381], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_381], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_vs_ref_" & $BLS12_381 ) run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp[BLS12_377], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BLS12_377], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_vs_ref_" & $BLS12_377 ) run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp[BW6_761], NotOnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], NotOnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g1_mul_vs_ref_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g2_add_double_bls12_377.nim b/tests/t_ec_shortw_prj_g2_add_double_bls12_377.nim index 3afc12f..6128e77 100644 --- a/tests/t_ec_shortw_prj_g2_add_double_bls12_377.nim +++ b/tests/t_ec_shortw_prj_g2_add_double_bls12_377.nim @@ -18,7 +18,7 @@ const Iters = 8 run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g2_add_double_" & $BLS12_377 ) diff --git a/tests/t_ec_shortw_prj_g2_add_double_bls12_381.nim b/tests/t_ec_shortw_prj_g2_add_double_bls12_381.nim index 50635ec..a4ddedc 100644 --- a/tests/t_ec_shortw_prj_g2_add_double_bls12_381.nim +++ b/tests/t_ec_shortw_prj_g2_add_double_bls12_381.nim @@ -18,7 +18,7 @@ const Iters = 8 run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g2_add_double_" & $BLS12_381 ) diff --git a/tests/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim b/tests/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim index 009414e..ac715bf 100644 --- a/tests/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim +++ b/tests/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim @@ -18,7 +18,7 @@ const Iters = 8 run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g2_add_double_" & $BN254_Snarks ) diff --git a/tests/t_ec_shortw_prj_g2_add_double_bw6_761.nim b/tests/t_ec_shortw_prj_g2_add_double_bw6_761.nim index 1745a6b..0b63af3 100644 --- a/tests/t_ec_shortw_prj_g2_add_double_bw6_761.nim +++ b/tests/t_ec_shortw_prj_g2_add_double_bw6_761.nim @@ -17,7 +17,7 @@ const Iters = 8 run_EC_addition_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_g2_add_double_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim b/tests/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim index 22092bb..ad3e825 100644 --- a/tests/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim +++ b/tests/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim @@ -18,7 +18,7 @@ const Iters = 12 run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BLS12_377 ) diff --git a/tests/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim b/tests/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim index 9fa181b..b94e42c 100644 --- a/tests/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim +++ b/tests/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim @@ -18,7 +18,7 @@ const Iters = 12 run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BLS12_381 ) diff --git a/tests/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim b/tests/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim index 4e0857e..6a9697f 100644 --- a/tests/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim +++ b/tests/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim @@ -18,7 +18,7 @@ const Iters = 12 run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BN254_Snarks ) diff --git a/tests/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim b/tests/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim index bcd58be..fc30cfc 100644 --- a/tests/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim +++ b/tests/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim @@ -17,7 +17,7 @@ const Iters = 12 run_EC_mixed_add_impl( - ec = ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], OnTwist], Iters = Iters, moduleName = "test_ec_shortweierstrass_projective_mixed_add_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim b/tests/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim index a174961..b407647 100644 --- a/tests/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim +++ b/tests/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_distributive_" & $BLS12_377 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim b/tests/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim index fe166bf..15184ad 100644 --- a/tests/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim +++ b/tests/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_distributive_" & $BLS12_381 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim b/tests/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim index 133a18b..c29a1a1 100644 --- a/tests/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim +++ b/tests/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_distributive_" & $BN254_Snarks ) diff --git a/tests/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim b/tests/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim index 0ac2da9..9c98f85 100644 --- a/tests/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim +++ b/tests/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim @@ -18,7 +18,7 @@ const ItersMul = Iters div 4 run_EC_mul_distributive_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_distributive_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim b/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim index c37530f..dd461b6 100644 --- a/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim +++ b/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_sanity_" & $BLS12_377 ) @@ -52,5 +52,5 @@ run_EC_mul_sanity_tests( # bool(impl.isInf()) # bool(reference.isInf()) # -# test(ECP_ShortW_Proj[Fp2[BLS12_377]], bits = BLS12_377.getCurveOrderBitwidth(), randZ = false) -# test(ECP_ShortW_Proj[Fp2[BLS12_377]], bits = BLS12_377.getCurveOrderBitwidth(), randZ = true) +# test(ECP_ShortW_Prj[Fp2[BLS12_377]], bits = BLS12_377.getCurveOrderBitwidth(), randZ = false) +# test(ECP_ShortW_Prj[Fp2[BLS12_377]], bits = BLS12_377.getCurveOrderBitwidth(), randZ = true) diff --git a/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim b/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim index 891a94c..574d5a9 100644 --- a/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim +++ b/tests/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_sanity_" & $BLS12_381 ) @@ -52,5 +52,5 @@ run_EC_mul_sanity_tests( # bool(impl.isInf()) # bool(reference.isInf()) # -# test(ECP_ShortW_Proj[Fp2[BLS12_381]], bits = BLS12_381.getCurveOrderBitwidth(), randZ = false) -# test(ECP_ShortW_Proj[Fp2[BLS12_381]], bits = BLS12_381.getCurveOrderBitwidth(), randZ = true) +# test(ECP_ShortW_Prj[Fp2[BLS12_381]], bits = BLS12_381.getCurveOrderBitwidth(), randZ = false) +# test(ECP_ShortW_Prj[Fp2[BLS12_381]], bits = BLS12_381.getCurveOrderBitwidth(), randZ = true) diff --git a/tests/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim b/tests/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim index 0a3d92e..f06360c 100644 --- a/tests/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim +++ b/tests/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_sanity_" & $BN254_Snarks ) @@ -52,5 +52,5 @@ run_EC_mul_sanity_tests( # bool(impl.isInf()) # bool(reference.isInf()) # -# test(ECP_ShortW_Proj[Fp2[BN254_Snarks]], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = false) -# test(ECP_ShortW_Proj[Fp2[BN254_Snarks]], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = true) +# test(ECP_ShortW_Prj[Fp2[BN254_Snarks]], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = false) +# test(ECP_ShortW_Prj[Fp2[BN254_Snarks]], bits = BN254_Snarks.getCurveOrderBitwidth(), randZ = true) diff --git a/tests/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim b/tests/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim index 0362a10..94e56e7 100644 --- a/tests/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim +++ b/tests/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim @@ -18,7 +18,7 @@ const ItersMul = Iters div 4 run_EC_mul_sanity_tests( - ec = ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_sanity_" & $BW6_761 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim index 2440fdc..bd4d1c0 100644 --- a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim +++ b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp2[BLS12_377], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_377], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_vs_ref_" & $BLS12_377 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim index f1e1a18..811e55c 100644 --- a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim +++ b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp2[BLS12_381], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BLS12_381], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_vs_ref_" & $BLS12_381 ) diff --git a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim index 0e019ac..2595aa9 100644 --- a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim +++ b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim @@ -19,7 +19,7 @@ const ItersMul = Iters div 4 run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp2[BN254_Snarks], OnTwist], + ec = ECP_ShortW_Prj[Fp2[BN254_Snarks], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_vs_ref_" & $BN254_Snarks ) diff --git a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim index bcb0fb6..6c6daf5 100644 --- a/tests/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim +++ b/tests/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim @@ -18,7 +18,7 @@ const ItersMul = Iters div 4 run_EC_mul_vs_ref_impl( - ec = ECP_ShortW_Proj[Fp[BW6_761], OnTwist], + ec = ECP_ShortW_Prj[Fp[BW6_761], OnTwist], ItersMul = ItersMul, moduleName = "test_ec_shortweierstrass_projective_g2_mul_vs_ref_" & $BW6_761 ) diff --git a/tests/t_ec_template.nim b/tests/t_ec_template.nim index aa128df..96477cf 100644 --- a/tests/t_ec_template.nim +++ b/tests/t_ec_template.nim @@ -441,7 +441,7 @@ proc run_EC_mixed_add_impl*( let a = rng.random_point(EC, randZ, gen) let b = rng.random_point(EC, randZ, gen) var bAff: ECP_ShortW_Aff[EC.F, EC.Tw] - when b is ECP_ShortW_Proj: + when b is ECP_ShortW_Prj: bAff.affineFromProjective(b) else: bAff.affineFromJacobian(b) diff --git a/tests/t_pairing_bls12_377_line_functions.nim b/tests/t_pairing_bls12_377_line_functions.nim index a9d0d53..904817c 100644 --- a/tests/t_pairing_bls12_377_line_functions.nim +++ b/tests/t_pairing_bls12_377_line_functions.nim @@ -70,8 +70,8 @@ suite "Pairing - Line Functions on BLS12-377" & " [" & $WordBitwidth & "-bit mod proc test_line_double(C: static Curve, randZ: bool, gen: RandomGen) = for _ in 0 ..< Iters: let P = rng.random_point(ECP_ShortW_Aff[Fp[C], NotOnTwist], gen) - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) - let Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) + let Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) var l: Line[Fp2[C]] var T2: typeof(Q) @@ -92,8 +92,8 @@ suite "Pairing - Line Functions on BLS12-377" & " [" & $WordBitwidth & "-bit mod proc test_line_add(C: static Curve, randZ: bool, gen: RandomGen) = for _ in 0 ..< Iters: let P = rng.random_point(ECP_ShortW_Aff[Fp[C], NotOnTwist], gen) - let Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) + let Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) var l: Line[Fp2[C]] var TQ{.noInit.}: typeof(T) diff --git a/tests/t_pairing_bls12_381_line_functions.nim b/tests/t_pairing_bls12_381_line_functions.nim index 832e58c..808da28 100644 --- a/tests/t_pairing_bls12_381_line_functions.nim +++ b/tests/t_pairing_bls12_381_line_functions.nim @@ -70,8 +70,8 @@ suite "Pairing - Line Functions on BLS12-381" & " [" & $WordBitwidth & "-bit mod proc test_line_double(C: static Curve, randZ: bool, gen: RandomGen) = for _ in 0 ..< Iters: let P = rng.random_point(ECP_ShortW_Aff[Fp[C], NotOnTwist], gen) - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) - let Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) + let Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) var l: Line[Fp2[C]] var T2: typeof(Q) @@ -92,8 +92,8 @@ suite "Pairing - Line Functions on BLS12-381" & " [" & $WordBitwidth & "-bit mod proc test_line_add(C: static Curve, randZ: bool, gen: RandomGen) = for _ in 0 ..< Iters: let P = rng.random_point(ECP_ShortW_Aff[Fp[C], NotOnTwist], gen) - let Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) - var T = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) + let Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) + var T = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) var l: Line[Fp2[C]] var TQ{.noInit.}: typeof(T) diff --git a/tests/t_pairing_template.nim b/tests/t_pairing_template.nim index a4d1a71..0dc5c0d 100644 --- a/tests/t_pairing_template.nim +++ b/tests/t_pairing_template.nim @@ -61,8 +61,8 @@ template runPairingTests*(Iters: static int, C: static Curve, pairing_fn: untype proc test_bilinearity_double_impl(randZ: bool, gen: RandomGen) = for _ in 0 ..< Iters: - let P = rng.random_point(ECP_ShortW_Proj[Fp[C], NotOnTwist], randZ, gen) - let Q = rng.random_point(ECP_ShortW_Proj[Fp2[C], OnTwist], randZ, gen) + let P = rng.random_point(ECP_ShortW_Prj[Fp[C], NotOnTwist], randZ, gen) + let Q = rng.random_point(ECP_ShortW_Prj[Fp2[C], OnTwist], randZ, gen) var P2: typeof(P) var Q2: typeof(Q)