mirror of
https://github.com/status-im/constantine.git
synced 2025-02-20 16:08:34 +00:00
Don't dump all in "backend" (#184)
* backend -> math * towers -> extension fields * move ISA and compiler specific code out of math/ * fix export
This commit is contained in:
parent
5bc6d1d426
commit
ffacf61e8a
@ -66,7 +66,7 @@ After [installation](#installation), the available high-level protocols are:
|
||||
_The backend, unlike protocols, is not public. Here be dragons._
|
||||
|
||||
At the moment the following curves are implemented, adding a new curve only requires adding the prime modulus
|
||||
and its bitsize in [constantine/config/curves.nim](constantine/backend/config/curves_declaration.nim).
|
||||
and its bitsize in [constantine/config/curves.nim](constantine/math/config/curves_declaration.nim).
|
||||
|
||||
The following curves are configured:
|
||||
|
||||
@ -81,7 +81,7 @@ The following curves are configured:
|
||||
- Jubjub, a curve embedded in BLS12-381 scalar field to be used in zk-SNARKS circuits.
|
||||
- Bandersnatch, a more efficient curve embedded in BLS12-381 scalar field to be used in zk-SNARKS circuits.
|
||||
- Other curves
|
||||
- Curve25519, used in ed25519 and X25519 from TLS 1.3 protocol and the Signal protocol.
|
||||
- Edwards25519, used in ed25519 and X25519 from TLS 1.3 protocol and the Signal protocol.
|
||||
With Ristretto, it can be used in bulletproofs.
|
||||
|
||||
## Installation
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import
|
||||
# Internal
|
||||
../constantine/backend/config/common,
|
||||
../constantine/platforms/abstractions,
|
||||
# Helpers
|
||||
../helpers/prng_unsafe,
|
||||
./platforms,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/elliptic/[
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/elliptic/[
|
||||
ec_shortweierstrass_projective,
|
||||
ec_shortweierstrass_jacobian],
|
||||
# Helpers
|
||||
@ -34,7 +34,7 @@ const AvailableCurves = [
|
||||
# P224,
|
||||
BN254_Nogami,
|
||||
BN254_Snarks,
|
||||
# Curve25519,
|
||||
# Edwards25519,
|
||||
# P256,
|
||||
# Secp256k1,
|
||||
BLS12_377,
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/backend/elliptic/[
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
../constantine/math/elliptic/[
|
||||
ec_shortweierstrass_projective,
|
||||
ec_shortweierstrass_jacobian],
|
||||
# Helpers
|
||||
@ -35,7 +35,7 @@ const AvailableCurves = [
|
||||
# P224,
|
||||
BN254_Nogami,
|
||||
BN254_Snarks,
|
||||
# Curve25519,
|
||||
# Edwards25519,
|
||||
# P256,
|
||||
# Secp256k1,
|
||||
BLS12_377,
|
||||
|
@ -14,10 +14,11 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[curves, common],
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/io/io_bigints,
|
||||
../constantine/backend/elliptic/[
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/io/io_bigints,
|
||||
../constantine/math/elliptic/[
|
||||
ec_shortweierstrass_affine,
|
||||
ec_shortweierstrass_projective,
|
||||
ec_shortweierstrass_jacobian,
|
||||
@ -27,7 +28,7 @@ import
|
||||
./platforms,
|
||||
./bench_blueprint,
|
||||
# Reference unsafe scalar multiplication
|
||||
../tests/backend/support/ec_reference_scalar_mult
|
||||
../tests/math/support/ec_reference_scalar_mult
|
||||
|
||||
export notes
|
||||
proc separator*() = separator(177)
|
||||
|
@ -14,10 +14,11 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[common, curves],
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/backend/curves/zoo_square_roots,
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
../constantine/math/curves/zoo_square_roots,
|
||||
# Helpers
|
||||
../helpers/prng_unsafe,
|
||||
./bench_blueprint
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[curves, common],
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/io/io_bigints,
|
||||
../constantine/backend/curves/zoo_square_roots,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/io/io_bigints,
|
||||
../constantine/math/curves/zoo_square_roots,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_fields_template
|
||||
@ -29,7 +29,7 @@ const AvailableCurves = [
|
||||
# P224,
|
||||
BN254_Nogami,
|
||||
BN254_Snarks,
|
||||
Curve25519,
|
||||
Edwards25519,
|
||||
Bandersnatch,
|
||||
P256,
|
||||
Secp256k1,
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_fields_template,
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_fields_template,
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_fields_template,
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_fields_template,
|
||||
|
@ -14,9 +14,10 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[curves, common],
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/[prng_unsafe, static_for],
|
||||
./platforms,
|
||||
|
@ -8,13 +8,15 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[common, curves, type_bigint, type_ff],
|
||||
../constantine/backend/[towers, hashes],
|
||||
../constantine/backend/io/[io_bigints, io_ec],
|
||||
../constantine/backend/elliptic/[
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/extension_fields,
|
||||
../constantine/math/io/[io_bigints, io_ec],
|
||||
../constantine/math/elliptic/[
|
||||
ec_shortweierstrass_affine,
|
||||
ec_shortweierstrass_projective],
|
||||
../constantine/backend/hash_to_curve/hash_to_curve,
|
||||
../constantine/hash_to_curve/hash_to_curve,
|
||||
../constantine/hashes,
|
||||
# Helpers
|
||||
../helpers/prng_unsafe,
|
||||
./bench_blueprint
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_pairing_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_pairing_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_pairing_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_pairing_template,
|
||||
|
@ -14,18 +14,19 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[curves, common],
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/backend/ec_shortweierstrass,
|
||||
../constantine/backend/curves/zoo_subgroups,
|
||||
../constantine/backend/pairing/[
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
../constantine/math/ec_shortweierstrass,
|
||||
../constantine/math/curves/zoo_subgroups,
|
||||
../constantine/math/pairing/[
|
||||
cyclotomic_subgroup,
|
||||
lines_eval,
|
||||
pairing_bls12,
|
||||
pairing_bn
|
||||
],
|
||||
../constantine/backend/curves/zoo_pairings,
|
||||
../constantine/math/curves/zoo_pairings,
|
||||
# Helpers
|
||||
../helpers/prng_unsafe,
|
||||
./bench_blueprint
|
||||
|
@ -1,6 +1,6 @@
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/hashes,
|
||||
../constantine/hashes,
|
||||
# Helpers
|
||||
../helpers/prng_unsafe,
|
||||
./bench_blueprint
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_summary_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_summary_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_summary_template,
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/curves,
|
||||
../constantine/backend/arithmetic,
|
||||
../constantine/backend/towers,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/arithmetic,
|
||||
../constantine/math/extension_fields,
|
||||
# Helpers
|
||||
../helpers/static_for,
|
||||
./bench_summary_template,
|
||||
|
@ -14,21 +14,23 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../constantine/backend/config/[curves, common],
|
||||
../constantine/backend/[arithmetic, hashes, towers],
|
||||
../constantine/backend/elliptic/[
|
||||
../constantine/platforms/abstractions,
|
||||
../constantine/math/config/curves,
|
||||
../constantine/math/[arithmetic, extension_fields],
|
||||
../constantine/math/elliptic/[
|
||||
ec_shortweierstrass_affine,
|
||||
ec_shortweierstrass_projective,
|
||||
ec_shortweierstrass_jacobian,
|
||||
ec_scalar_mul, ec_endomorphism_accel],
|
||||
../constantine/backend/curves/zoo_subgroups,
|
||||
../constantine/backend/hash_to_curve/hash_to_curve,
|
||||
../constantine/backend/pairing/[
|
||||
../constantine/math/curves/zoo_subgroups,
|
||||
../constantine/math/pairing/[
|
||||
cyclotomic_subgroup,
|
||||
pairing_bls12,
|
||||
pairing_bn
|
||||
],
|
||||
../constantine/backend/curves/zoo_pairings,
|
||||
../constantine/math/curves/zoo_pairings,
|
||||
../constantine/hashes,
|
||||
../constantine/hash_to_curve/hash_to_curve,
|
||||
# Helpers
|
||||
../helpers/[prng_unsafe, static_for],
|
||||
./bench_blueprint
|
||||
|
@ -1,7 +1,7 @@
|
||||
packageName = "constantine"
|
||||
version = "0.0.1"
|
||||
author = "Status Research & Development GmbH"
|
||||
description = "This library provides constant time big int primitives."
|
||||
description = "This library provides thoroughly tested and highly-optimized implementations of cryptography protocols."
|
||||
license = "MIT or Apache License 2.0"
|
||||
|
||||
# Dependencies
|
||||
@ -23,166 +23,166 @@ const buildParallel = "test_parallel.txt"
|
||||
const testDesc: seq[tuple[path: string, useGMP: bool]] = @[
|
||||
# Primitives
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_primitives.nim", false),
|
||||
("tests/backend/t_primitives_extended_precision.nim", false),
|
||||
("tests/math/t_primitives.nim", false),
|
||||
("tests/math/t_primitives_extended_precision.nim", false),
|
||||
# Big ints
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_io_bigints.nim", false),
|
||||
("tests/backend/t_io_unsaturated.nim", false),
|
||||
("tests/backend/t_bigints.nim", false),
|
||||
("tests/backend/t_bigints_multimod.nim", false),
|
||||
("tests/backend/t_bigints_mod_vs_gmp.nim", true),
|
||||
("tests/backend/t_bigints_mul_vs_gmp.nim", true),
|
||||
("tests/backend/t_bigints_mul_high_words_vs_gmp.nim", true),
|
||||
("tests/math/t_io_bigints.nim", false),
|
||||
("tests/math/t_io_unsaturated.nim", false),
|
||||
("tests/math/t_bigints.nim", false),
|
||||
("tests/math/t_bigints_multimod.nim", false),
|
||||
("tests/math/t_bigints_mod_vs_gmp.nim", true),
|
||||
("tests/math/t_bigints_mul_vs_gmp.nim", true),
|
||||
("tests/math/t_bigints_mul_high_words_vs_gmp.nim", true),
|
||||
# Field
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_io_fields", false),
|
||||
("tests/backend/t_finite_fields.nim", false),
|
||||
("tests/backend/t_finite_fields_conditional_arithmetic.nim", false),
|
||||
("tests/backend/t_finite_fields_mulsquare.nim", false),
|
||||
("tests/backend/t_finite_fields_sqrt.nim", false),
|
||||
("tests/backend/t_finite_fields_powinv.nim", false),
|
||||
("tests/backend/t_finite_fields_vs_gmp.nim", true),
|
||||
("tests/backend/t_fp_cubic_root.nim", false),
|
||||
("tests/math/t_io_fields", false),
|
||||
("tests/math/t_finite_fields.nim", false),
|
||||
("tests/math/t_finite_fields_conditional_arithmetic.nim", false),
|
||||
("tests/math/t_finite_fields_mulsquare.nim", false),
|
||||
("tests/math/t_finite_fields_sqrt.nim", false),
|
||||
("tests/math/t_finite_fields_powinv.nim", false),
|
||||
("tests/math/t_finite_fields_vs_gmp.nim", true),
|
||||
("tests/math/t_fp_cubic_root.nim", false),
|
||||
# Double-precision finite fields
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_finite_fields_double_precision.nim", false),
|
||||
("tests/math/t_finite_fields_double_precision.nim", false),
|
||||
# Towers of extension fields
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_fp2.nim", false),
|
||||
("tests/backend/t_fp2_sqrt.nim", false),
|
||||
("tests/backend/t_fp4.nim", false),
|
||||
("tests/backend/t_fp6_bn254_snarks.nim", false),
|
||||
("tests/backend/t_fp6_bls12_377.nim", false),
|
||||
("tests/backend/t_fp6_bls12_381.nim", false),
|
||||
("tests/backend/t_fp6_bw6_761.nim", false),
|
||||
("tests/backend/t_fp12_bn254_snarks.nim", false),
|
||||
("tests/backend/t_fp12_bls12_377.nim", false),
|
||||
("tests/backend/t_fp12_bls12_381.nim", false),
|
||||
("tests/backend/t_fp12_exponentiation.nim", false),
|
||||
("tests/backend/t_fp12_anti_regression.nim", false),
|
||||
("tests/math/t_fp2.nim", false),
|
||||
("tests/math/t_fp2_sqrt.nim", false),
|
||||
("tests/math/t_fp4.nim", false),
|
||||
("tests/math/t_fp6_bn254_snarks.nim", false),
|
||||
("tests/math/t_fp6_bls12_377.nim", false),
|
||||
("tests/math/t_fp6_bls12_381.nim", false),
|
||||
("tests/math/t_fp6_bw6_761.nim", false),
|
||||
("tests/math/t_fp12_bn254_snarks.nim", false),
|
||||
("tests/math/t_fp12_bls12_377.nim", false),
|
||||
("tests/math/t_fp12_bls12_381.nim", false),
|
||||
("tests/math/t_fp12_exponentiation.nim", false),
|
||||
("tests/math/t_fp12_anti_regression.nim", false),
|
||||
|
||||
("tests/backend/t_fp4_frobenius.nim", false),
|
||||
("tests/backend/t_fp6_frobenius.nim", false),
|
||||
("tests/backend/t_fp12_frobenius.nim", false),
|
||||
("tests/math/t_fp4_frobenius.nim", false),
|
||||
("tests/math/t_fp6_frobenius.nim", false),
|
||||
("tests/math/t_fp12_frobenius.nim", false),
|
||||
|
||||
# Elliptic curve arithmetic
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_ec_conversion.nim", false),
|
||||
("tests/math/t_ec_conversion.nim", false),
|
||||
|
||||
# Elliptic curve arithmetic G1
|
||||
# ----------------------------------------------------------
|
||||
# ("tests/backend/t_ec_shortw_prj_g1_add_double.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g1_mul_sanity.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g1_mul_distri.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g1_mul_vs_ref.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g1_mixed_add.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g1_add_double.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g1_mul_sanity.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g1_mul_distri.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g1_mul_vs_ref.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g1_mixed_add.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_jac_g1_add_double.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g1_mul_sanity.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g1_mul_distri.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g1_mul_vs_ref.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g1_mixed_add.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g1_add_double.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g1_mul_sanity.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g1_mul_distri.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g1_mul_vs_ref.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g1_mixed_add.nim", false),
|
||||
|
||||
("tests/backend/t_ec_twedwards_prj_add_double", false),
|
||||
("tests/backend/t_ec_twedwards_prj_mul_sanity", false),
|
||||
("tests/backend/t_ec_twedwards_prj_mul_distri", false),
|
||||
("tests/math/t_ec_twedwards_prj_add_double", false),
|
||||
("tests/math/t_ec_twedwards_prj_mul_sanity", false),
|
||||
("tests/math/t_ec_twedwards_prj_mul_distri", false),
|
||||
|
||||
|
||||
# Elliptic curve arithmetic G2
|
||||
# ----------------------------------------------------------
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_add_double_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_sanity_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_distri_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mul_vs_ref_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mixed_add_bn254_snarks.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_add_double_bls12_381.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_add_double_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_sanity_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_distri_bls12_381.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mul_vs_ref_bls12_381.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mixed_add_bls12_381.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_add_double_bls12_377.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_add_double_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_sanity_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_distri_bls12_377.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mul_vs_ref_bls12_377.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mixed_add_bls12_377.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_add_double_bw6_761.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim", false),
|
||||
("tests/backend/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_add_double_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_sanity_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_prj_g2_mul_distri_bw6_761.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mul_vs_ref_bw6_761.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_g2_mixed_add_bw6_761.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_add_double_bn254_snarks.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_sanity_bn254_snarks.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_distri_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mul_vs_ref_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mixed_add_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_add_double_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_sanity_bn254_snarks.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_distri_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mul_vs_ref_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mixed_add_bn254_snarks.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_add_double_bls12_381.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_sanity_bls12_381.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_distri_bls12_381.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mul_vs_ref_bls12_381.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mixed_add_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_add_double_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_sanity_bls12_381.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_distri_bls12_381.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mul_vs_ref_bls12_381.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mixed_add_bls12_381.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_add_double_bls12_377.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_sanity_bls12_377.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_distri_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mul_vs_ref_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mixed_add_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_add_double_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_sanity_bls12_377.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_distri_bls12_377.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mul_vs_ref_bls12_377.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mixed_add_bls12_377.nim", false),
|
||||
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_add_double_bw6_761.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_sanity_bw6_761.nim", false),
|
||||
# ("tests/backend/t_ec_shortw_jac_g2_mul_distri_bw6_761.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mul_vs_ref_bw6_761.nim", false),
|
||||
("tests/backend/t_ec_shortw_jac_g2_mixed_add_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_add_double_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_sanity_bw6_761.nim", false),
|
||||
# ("tests/math/t_ec_shortw_jac_g2_mul_distri_bw6_761.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mul_vs_ref_bw6_761.nim", false),
|
||||
("tests/math/t_ec_shortw_jac_g2_mixed_add_bw6_761.nim", false),
|
||||
|
||||
# Elliptic curve arithmetic vs Sagemath
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_ec_frobenius.nim", false),
|
||||
("tests/backend/t_ec_sage_bn254_nogami.nim", false),
|
||||
("tests/backend/t_ec_sage_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_sage_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_sage_bls12_381.nim", false),
|
||||
("tests/math/t_ec_frobenius.nim", false),
|
||||
("tests/math/t_ec_sage_bn254_nogami.nim", false),
|
||||
("tests/math/t_ec_sage_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_sage_bls12_377.nim", false),
|
||||
("tests/math/t_ec_sage_bls12_381.nim", false),
|
||||
# Edge cases highlighted by past bugs
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_ec_shortw_prj_edge_cases.nim", false),
|
||||
("tests/math/t_ec_shortw_prj_edge_cases.nim", false),
|
||||
|
||||
# Subgroups and cofactors
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_ec_subgroups_bn254_nogami.nim", false),
|
||||
("tests/backend/t_ec_subgroups_bn254_snarks.nim", false),
|
||||
("tests/backend/t_ec_subgroups_bls12_377.nim", false),
|
||||
("tests/backend/t_ec_subgroups_bls12_381.nim", false),
|
||||
("tests/math/t_ec_subgroups_bn254_nogami.nim", false),
|
||||
("tests/math/t_ec_subgroups_bn254_snarks.nim", false),
|
||||
("tests/math/t_ec_subgroups_bls12_377.nim", false),
|
||||
("tests/math/t_ec_subgroups_bls12_381.nim", false),
|
||||
|
||||
("tests/backend/t_pairing_bn254_nogami_gt_subgroup.nim", false),
|
||||
("tests/backend/t_pairing_bn254_snarks_gt_subgroup.nim", false),
|
||||
("tests/backend/t_pairing_bls12_377_gt_subgroup.nim", false),
|
||||
("tests/backend/t_pairing_bls12_381_gt_subgroup.nim", false),
|
||||
("tests/backend/t_pairing_bw6_761_gt_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bn254_nogami_gt_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bn254_snarks_gt_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bls12_377_gt_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bls12_381_gt_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bw6_761_gt_subgroup.nim", false),
|
||||
|
||||
# Pairing
|
||||
# ----------------------------------------------------------
|
||||
# ("tests/backend/t_pairing_bls12_377_line_functions.nim", false),
|
||||
# ("tests/backend/t_pairing_bls12_381_line_functions.nim", false),
|
||||
("tests/backend/t_pairing_mul_fp12_by_lines.nim", false),
|
||||
("tests/backend/t_pairing_cyclotomic_subgroup.nim", false),
|
||||
("tests/backend/t_pairing_bn254_nogami_optate.nim", false),
|
||||
("tests/backend/t_pairing_bn254_snarks_optate.nim", false),
|
||||
("tests/backend/t_pairing_bls12_377_optate.nim", false),
|
||||
("tests/backend/t_pairing_bls12_381_optate.nim", false),
|
||||
("tests/backend/t_pairing_bls12_381_multi.nim", false),
|
||||
# ("tests/math/t_pairing_bls12_377_line_functions.nim", false),
|
||||
# ("tests/math/t_pairing_bls12_381_line_functions.nim", false),
|
||||
("tests/math/t_pairing_mul_fp12_by_lines.nim", false),
|
||||
("tests/math/t_pairing_cyclotomic_subgroup.nim", false),
|
||||
("tests/math/t_pairing_bn254_nogami_optate.nim", false),
|
||||
("tests/math/t_pairing_bn254_snarks_optate.nim", false),
|
||||
("tests/math/t_pairing_bls12_377_optate.nim", false),
|
||||
("tests/math/t_pairing_bls12_381_optate.nim", false),
|
||||
("tests/math/t_pairing_bls12_381_multi.nim", false),
|
||||
|
||||
# Hashing to elliptic curves
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_hash_to_field.nim", false),
|
||||
("tests/backend/t_hash_to_curve.nim", false),
|
||||
("tests/math/t_hash_to_field.nim", false),
|
||||
("tests/math/t_hash_to_curve.nim", false),
|
||||
|
||||
# Prime order fields
|
||||
# ----------------------------------------------------------
|
||||
("tests/backend/t_fr.nim", false),
|
||||
("tests/math/t_fr.nim", false),
|
||||
|
||||
# Hashing vs OpenSSL
|
||||
# ----------------------------------------------------------
|
||||
@ -196,20 +196,20 @@ const testDesc: seq[tuple[path: string, useGMP: bool]] = @[
|
||||
|
||||
# For temporary (hopefully) investigation that can only be reproduced in CI
|
||||
const useDebug = [
|
||||
"tests/backend/t_bigints.nim",
|
||||
"tests/backend/t_hash_sha256_vs_openssl.nim",
|
||||
"tests/math/t_bigints.nim",
|
||||
"tests/math/t_hash_sha256_vs_openssl.nim",
|
||||
]
|
||||
|
||||
# Tests that uses sequences require Nim GC, stack scanning and nil pointer passed to openarray
|
||||
# In particular the tests that uses the json test vectors, don't sanitize them.
|
||||
# we do use gc:none to help
|
||||
const skipSanitizers = [
|
||||
"tests/backend/t_ec_sage_bn254_nogami.nim",
|
||||
"tests/backend/t_ec_sage_bn254_snarks.nim",
|
||||
"tests/backend/t_ec_sage_bls12_377.nim",
|
||||
"tests/backend/t_ec_sage_bls12_381.nim",
|
||||
"tests/backend/t_hash_to_field.nim",
|
||||
"tests/backend/t_hash_to_curve.nim"
|
||||
"tests/math/t_ec_sage_bn254_nogami.nim",
|
||||
"tests/math/t_ec_sage_bn254_snarks.nim",
|
||||
"tests/math/t_ec_sage_bls12_377.nim",
|
||||
"tests/math/t_ec_sage_bls12_381.nim",
|
||||
"tests/math/t_hash_to_field.nim",
|
||||
"tests/math/t_hash_to_curve.nim"
|
||||
]
|
||||
|
||||
when defined(windows):
|
||||
|
@ -1,36 +0,0 @@
|
||||
# Constantine
|
||||
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
||||
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import std/macros
|
||||
|
||||
proc replaceNodes(ast: NimNode, what: NimNode, by: NimNode): NimNode =
|
||||
# Replace "what" ident node by "by"
|
||||
proc inspect(node: NimNode): NimNode =
|
||||
case node.kind:
|
||||
of {nnkIdent, nnkSym}:
|
||||
if node.eqIdent(what):
|
||||
return by
|
||||
return node
|
||||
of nnkEmpty:
|
||||
return node
|
||||
of nnkLiterals:
|
||||
return node
|
||||
else:
|
||||
var rTree = node.kind.newTree()
|
||||
for child in node:
|
||||
rTree.add inspect(child)
|
||||
return rTree
|
||||
result = inspect(ast)
|
||||
|
||||
macro staticFor*(idx: untyped{nkIdent}, start, stopEx: static int, body: untyped): untyped =
|
||||
result = newStmtList()
|
||||
for i in start ..< stopEx:
|
||||
result.add nnkBlockStmt.newTree(
|
||||
ident("unrolledIter_" & $idx & $i),
|
||||
body.replaceNodes(idx, newLit i)
|
||||
)
|
@ -7,24 +7,21 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
./backend/config/[
|
||||
common, curves, type_bigint, type_ff
|
||||
],
|
||||
./backend/[
|
||||
./platforms/abstractions,
|
||||
./math/config/curves,
|
||||
./math/[
|
||||
ec_shortweierstrass,
|
||||
hash_to_curve/hash_to_curve,
|
||||
hashes,
|
||||
towers,
|
||||
extension_fields,
|
||||
arithmetic,
|
||||
signatures/bls_signatures,
|
||||
curves/zoo_subgroups,
|
||||
primitives
|
||||
curves/zoo_subgroups
|
||||
],
|
||||
./backend/io/[io_bigints, io_fields]
|
||||
./math/io/[io_bigints, io_fields],
|
||||
hashes,
|
||||
signatures/bls_signatures
|
||||
|
||||
export
|
||||
curves, # generic sandwich on matchingBigInt
|
||||
towers, # generic sandwich on extension field access
|
||||
extension_fields, # generic sandwich on extension field access
|
||||
hashes, # generic sandwich on sha256
|
||||
ec_shortweierstrass # generic sandwich on affine
|
||||
|
||||
|
@ -7,13 +7,14 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
./backend/config/[common, curves],
|
||||
./backend/[arithmetic, towers],
|
||||
./backend/arithmetic/limbs_montgomery,
|
||||
./backend/ec_shortweierstrass,
|
||||
./backend/pairing/[pairing_bn, miller_loops, cyclotomic_subgroup],
|
||||
./backend/curves/zoo_subgroups,
|
||||
./backend/io/[io_bigints, io_fields]
|
||||
./platforms/abstractions,
|
||||
./math/config/curves,
|
||||
./math/[arithmetic, extension_fields],
|
||||
./math/arithmetic/limbs_montgomery,
|
||||
./math/ec_shortweierstrass,
|
||||
./math/pairing/[pairing_bn, miller_loops, cyclotomic_subgroup],
|
||||
./math/curves/zoo_subgroups,
|
||||
./math/io/[io_bigints, io_fields]
|
||||
|
||||
# ############################################################
|
||||
#
|
||||
|
@ -8,11 +8,12 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../platforms/[abstractions, endians],
|
||||
../hashes,
|
||||
../io/[endians, io_bigints, io_fields],
|
||||
../config/[common, curves, type_bigint, type_ff],
|
||||
../arithmetic/limbs_montgomery,
|
||||
../tower_field_extensions/extension_fields
|
||||
../math/io/[io_bigints, io_fields],
|
||||
../math/config/curves,
|
||||
../math/arithmetic/limbs_montgomery,
|
||||
../math/extension_fields/towers
|
||||
|
||||
# ############################################################
|
||||
#
|
@ -8,9 +8,10 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../primitives, ../arithmetic, ../towers,
|
||||
../curves/zoo_hash_to_curve,
|
||||
../elliptic/[
|
||||
../platforms/abstractions,
|
||||
../math/[arithmetic, extension_fields],
|
||||
../math/curves/zoo_hash_to_curve,
|
||||
../math/elliptic/[
|
||||
ec_shortweierstrass_projective,
|
||||
ec_shortweierstrass_jacobian,
|
||||
]
|
||||
@ -194,7 +195,7 @@ func h2c_isogeny_map*[F; G: static Subgroup](
|
||||
r.x.prod(rxn, ryd) # X = xn * yd
|
||||
r.x *= r.z # X = xn * xd * yd²
|
||||
r.y.square(r.z) # Y = xd² * yd²
|
||||
r.y *= rdx # Y = yd² * xd³
|
||||
r.y *= rxd # Y = yd² * xd³
|
||||
r.y *= ryn # Y = yn * yd² * xd³
|
||||
|
||||
func h2c_isogeny_map*[F; G: static Subgroup](
|
@ -8,9 +8,10 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../primitives, ../arithmetic, ../towers,
|
||||
../curves/zoo_hash_to_curve
|
||||
../platforms/abstractions,
|
||||
../math/config/curves,
|
||||
../math/[arithmetic, extension_fields],
|
||||
../math/curves/zoo_hash_to_curve
|
||||
|
||||
# ############################################################
|
||||
#
|
@ -8,13 +8,14 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../primitives, ../arithmetic, ../towers,
|
||||
../curves/[zoo_hash_to_curve, zoo_subgroups],
|
||||
../ec_shortweierstrass,
|
||||
../platforms/abstractions,
|
||||
../math/config/curves,
|
||||
../math/[arithmetic, extension_fields],
|
||||
../math/curves/[zoo_hash_to_curve, zoo_subgroups],
|
||||
../math/ec_shortweierstrass,
|
||||
./h2c_hash_to_field,
|
||||
./h2c_map_to_isocurve_swu,
|
||||
../isogeny/h2c_isogeny_maps,
|
||||
./h2c_isogeny_maps,
|
||||
../hashes
|
||||
|
||||
# ############################################################
|
@ -8,9 +8,7 @@
|
||||
|
||||
import
|
||||
std/macros,
|
||||
../config/common,
|
||||
../io/endians,
|
||||
../primitives/static_for
|
||||
../platforms/[abstractions, endians]
|
||||
|
||||
# SHA256, a hash function from the SHA2 family
|
||||
# --------------------------------------------------------------------------------
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives
|
||||
../../../platforms/abstractions
|
||||
|
||||
# ############################################################
|
||||
# #
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives
|
||||
../../../platforms/abstractions
|
||||
|
||||
# ############################################################
|
||||
#
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives,
|
||||
../../../platforms/abstractions,
|
||||
./limbs_asm_modular_x86,
|
||||
./limbs_asm_redc_mont_x86,
|
||||
./limbs_asm_mul_x86
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/[macros, algorithm],
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives,
|
||||
../../../platforms/abstractions,
|
||||
./limbs_asm_modular_x86,
|
||||
./limbs_asm_redc_mont_x86_adx_bmi2,
|
||||
./limbs_asm_mul_x86_adx_bmi2
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives
|
||||
../../../platforms/abstractions
|
||||
|
||||
# ############################################################
|
||||
#
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives
|
||||
../../../platforms/abstractions
|
||||
|
||||
# ############################################################
|
||||
#
|
||||
@ -620,7 +619,8 @@ func square_asm_adx*[rLen, aLen: static int](r: var Limbs[rLen], a: Limbs[aLen])
|
||||
|
||||
when isMainModule:
|
||||
import
|
||||
../../config/[type_bigint, common],
|
||||
../../../platforms/abstractions,
|
||||
../../config/type_bigint,
|
||||
../../arithmetic/limbs
|
||||
|
||||
type SW = SecretWord
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives,
|
||||
../../../platforms/abstractions,
|
||||
./limbs_asm_modular_x86
|
||||
|
||||
# ############################################################
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives,
|
||||
../../../platforms/abstractions,
|
||||
./limbs_asm_modular_x86
|
||||
|
||||
# ############################################################
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../../config/common,
|
||||
../../primitives
|
||||
../../../platforms/abstractions
|
||||
|
||||
# ############################################################
|
||||
#
|
@ -7,8 +7,8 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, type_bigint],
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
../config/type_bigint,
|
||||
./limbs,
|
||||
./limbs_extmul,
|
||||
./limbs_invmod,
|
@ -7,8 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, type_bigint],
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
../io/io_bigints,
|
||||
./limbs,
|
||||
./limbs_montgomery,
|
@ -27,8 +27,8 @@
|
||||
# which requires a prime
|
||||
|
||||
import
|
||||
../primitives,
|
||||
../config/[common, type_ff, curves_prop_field_core, curves_prop_field_derived],
|
||||
../../platforms/abstractions,
|
||||
../config/[type_ff, curves_prop_field_core, curves_prop_field_derived],
|
||||
./bigints, ./bigints_montgomery
|
||||
|
||||
when UseASM_X86_64:
|
||||
@ -100,7 +100,7 @@ func cswap*(a, b: var FF, ctl: CTBool) {.meter.} =
|
||||
# Routines for special field modulus form:
|
||||
# - Mersenne Prime (2ᵏ - 1),
|
||||
# - Generalized Mersenne Prime (NIST Prime P256: 2^256 - 2^224 + 2^192 + 2^96 - 1)
|
||||
# - Pseudo-Mersenne Prime (2^m - k for example Curve25519: 2^255 - 19)
|
||||
# - Pseudo-Mersenne Prime (2^m - k for example Edwards25519: 2^255 - 19)
|
||||
# - Golden Primes (φ^2 - φ - 1 with φ = 2ᵏ for example Ed448-Goldilocks: 2^448 - 2^224 - 1)
|
||||
# exist and can be implemented with compile-time specialization.
|
||||
|
@ -7,8 +7,8 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, curves, type_ff],
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
./bigints,
|
||||
./finite_fields,
|
||||
./limbs,
|
@ -7,8 +7,8 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../primitives,
|
||||
../config/[common, type_ff, curves],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../curves/zoo_square_roots,
|
||||
./bigints, ./finite_fields
|
||||
|
@ -6,9 +6,7 @@
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/common,
|
||||
../primitives
|
||||
import ../../platforms/abstractions
|
||||
|
||||
when UseASM_X86_32:
|
||||
import ./assembly/limbs_asm_x86
|
@ -6,9 +6,7 @@
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/common,
|
||||
../primitives
|
||||
import ../../platforms/abstractions
|
||||
|
||||
# No exceptions allowed
|
||||
{.push raises: [].}
|
@ -7,8 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/common,
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
./limbs
|
||||
|
||||
when UseASM_X86_64:
|
@ -7,8 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/common,
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
./limbs, ./limbs_unsaturated
|
||||
|
||||
# No exceptions allowed
|
@ -10,8 +10,7 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
../config/common,
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
./limbs, ./limbs_extmul
|
||||
|
||||
when UseASM_X86_32:
|
@ -6,9 +6,7 @@
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/common,
|
||||
../primitives
|
||||
import ../../platforms/abstractions
|
||||
|
||||
type
|
||||
SignedSecretWord* = distinct SecretWord
|
@ -152,7 +152,7 @@ declareCurves:
|
||||
coef_a: -5
|
||||
coef_d: "6389c12633c267cbc66e3bf86be3b6d8cb66677177e54f92b369f2f5188d58e7"
|
||||
|
||||
curve Curve25519: # Bernstein curve
|
||||
curve Edwards25519: # Bernstein curve
|
||||
bitwidth: 255
|
||||
modulus: "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"
|
||||
|
@ -9,7 +9,8 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
./type_bigint, ./common,
|
||||
../../platforms/abstractions,
|
||||
./type_bigint,
|
||||
./curves_declaration
|
||||
|
||||
export Curve
|
@ -10,7 +10,8 @@ import
|
||||
# Standard library
|
||||
std/macros,
|
||||
# Internal
|
||||
./type_bigint, ./type_ff, ./common,
|
||||
../../platforms/abstractions,
|
||||
./type_bigint, ./type_ff,
|
||||
./curves_declaration, ./curves_prop_field_core, ./curves_derived
|
||||
|
||||
# ############################################################
|
@ -7,8 +7,8 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
./type_bigint, ./common,
|
||||
../primitives,
|
||||
../../platforms/abstractions,
|
||||
./type_bigint,
|
||||
../io/io_bigints
|
||||
|
||||
# Precomputed constants
|
@ -6,7 +6,7 @@
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import ./common
|
||||
import ../../platforms/abstractions
|
||||
|
||||
func wordsRequired*(bits: int): int {.compileTime.} =
|
||||
## Compute the number of limbs required
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
./common,
|
||||
../../platforms/abstractions,
|
||||
./curves_declaration,
|
||||
./curves_prop_field_core
|
||||
|
@ -5,7 +5,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields],
|
||||
../arithmetic/finite_fields
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Curve precomputed parameters
|
||||
# -----------------------------------------------------------------
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields]
|
||||
|
||||
# BLS12_377 G1
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../towers,
|
||||
../io/io_towers
|
||||
../extension_fields,
|
||||
../io/io_extfields
|
||||
|
||||
# Frobenius map - on extension fields
|
||||
# -----------------------------------------------------------------
|
@ -7,12 +7,13 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, curves, type_bigint, type_ff],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../io/io_bigints,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../elliptic/[ec_shortweierstrass_affine, ec_shortweierstrass_projective],
|
||||
../pairing/[cyclotomic_subgroup, miller_loops],
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
# Slow generic implementation
|
||||
# ------------------------------------------------------------
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields],
|
||||
../arithmetic/finite_fields
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../arithmetic,
|
||||
../primitives,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../ec_shortweierstrass,
|
||||
../io/io_bigints,
|
||||
../isogeny/frobenius,
|
||||
../isogenies/frobenius,
|
||||
../curves/zoo_endomorphisms
|
||||
|
||||
func pow_bls12_377_abs_x[ECP: ECP_ShortW[Fp[BLS12_377], G1] or
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Curve precomputed parameters
|
||||
# -----------------------------------------------------------------
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields]
|
||||
|
||||
# BLS12_381 G1
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../towers,
|
||||
../io/io_towers
|
||||
../extension_fields,
|
||||
../io/io_extfields
|
||||
|
||||
# Frobenius map - on extension fields
|
||||
# -----------------------------------------------------------------
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/[io_fields, io_towers]
|
||||
../io/[io_fields, io_extfields]
|
||||
|
||||
# Hash-to-Curve map to isogenous BLS12-381 E'2 constants
|
||||
# -----------------------------------------------------------------
|
@ -7,9 +7,9 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_ff],
|
||||
../config/curves,
|
||||
../elliptic/ec_shortweierstrass_affine,
|
||||
../io/[io_fields, io_towers]
|
||||
../io/[io_fields, io_extfields]
|
||||
|
||||
# Generators
|
||||
# -----------------------------------------------------------------
|
@ -7,12 +7,13 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, curves, type_bigint, type_ff],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../io/io_bigints,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../elliptic/[ec_shortweierstrass_affine, ec_shortweierstrass_projective],
|
||||
../pairing/[cyclotomic_subgroup, miller_loops],
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
# Slow generic implementation
|
||||
# ------------------------------------------------------------
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Square Root Fp2 constants
|
||||
# -----------------------------------------------------------------
|
@ -8,13 +8,13 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../arithmetic,
|
||||
../primitives,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../ec_shortweierstrass,
|
||||
../io/io_bigints,
|
||||
../isogeny/frobenius,
|
||||
../isogenies/frobenius,
|
||||
../curves/zoo_endomorphisms
|
||||
|
||||
func pow_bls12_381_abs_x[ECP: ECP_ShortW[Fp[BLS12_381], G1] or
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Curve precomputed parameters
|
||||
# -----------------------------------------------------------------
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields]
|
||||
|
||||
# BN254_Nogami G1
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../towers,
|
||||
../io/io_towers
|
||||
../extension_fields,
|
||||
../io/io_extfields
|
||||
|
||||
# Frobenius map - on extension fields
|
||||
# -----------------------------------------------------------------
|
@ -7,12 +7,13 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, curves, type_bigint, type_ff],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../io/io_bigints,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../elliptic/[ec_shortweierstrass_affine, ec_shortweierstrass_projective],
|
||||
../pairing/[cyclotomic_subgroup, miller_loops],
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
# Slow generic implementation
|
||||
# ------------------------------------------------------------
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Square Root Fp2 constants
|
||||
# -----------------------------------------------------------------
|
@ -8,13 +8,13 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../arithmetic,
|
||||
../primitives,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../ec_shortweierstrass,
|
||||
../io/io_bigints,
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
func pow_BN254_Nogami_abs_u*[ECP: ECP_ShortW[Fp[BN254_Nogami], G1] or
|
||||
ECP_ShortW[Fp2[BN254_Nogami], G2]](
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Curve precomputed parameters
|
||||
# -----------------------------------------------------------------
|
@ -7,7 +7,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[curves, type_bigint, type_ff],
|
||||
../config/curves,
|
||||
../io/[io_bigints, io_fields]
|
||||
|
||||
# BN254_Snarks G1
|
@ -8,8 +8,8 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../towers,
|
||||
../io/io_towers
|
||||
../extension_fields,
|
||||
../io/io_extfields
|
||||
|
||||
# Frobenius map - on extension fields
|
||||
# -----------------------------------------------------------------
|
@ -7,12 +7,13 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
../config/[common, curves, type_bigint, type_ff],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../io/io_bigints,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../elliptic/[ec_shortweierstrass_affine, ec_shortweierstrass_projective],
|
||||
../pairing/[cyclotomic_subgroup, miller_loops],
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
# Slow generic implementation
|
||||
# ------------------------------------------------------------
|
@ -8,7 +8,7 @@
|
||||
|
||||
import
|
||||
../config/curves,
|
||||
../io/io_towers
|
||||
../io/io_extfields
|
||||
|
||||
# Square Root Fp2 constants
|
||||
# -----------------------------------------------------------------
|
@ -8,13 +8,13 @@
|
||||
|
||||
import
|
||||
# Internals
|
||||
../config/[common, curves],
|
||||
../../platforms/abstractions,
|
||||
../config/curves,
|
||||
../arithmetic,
|
||||
../primitives,
|
||||
../towers,
|
||||
../extension_fields,
|
||||
../ec_shortweierstrass,
|
||||
../io/io_bigints,
|
||||
../isogeny/frobenius
|
||||
../isogenies/frobenius
|
||||
|
||||
func pow_bn254_snarks_abs_u*[ECP: ECP_ShortW[Fp[BN254_Snarks], G1] or
|
||||
ECP_ShortW[Fp2[BN254_Snarks], G2]](
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user