Skip to content

Commit

Permalink
Fr: Finite Field parametrized by the curve order (#115)
Browse files Browse the repository at this point in the history
* Introduce Fr type: finite field over curve order. Need workaround for nim-lang/Nim#16774

* Split curve properties into core and derived

* Attach field properties to an instantiated field instead of the curve enum

* Workaround nim-lang/Nim#14021, yet another "working with types in macros" is difficult nim-lang/RFCs#44

* Implement finite field over prime order of a curve subgroup

* skip OpenSSL tests on windows
  • Loading branch information
mratsim authored Jan 21, 2021
1 parent ac63005 commit 638cb71
Show file tree
Hide file tree
Showing 52 changed files with 702 additions and 444 deletions.
2 changes: 1 addition & 1 deletion benchmarks/bench_fields_template.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ proc invEuclidBench*(T: typedesc, iters: int) =

proc invPowFermatBench*(T: typedesc, iters: int) =
let x = rng.random_unsafe(T)
const exponent = T.C.getInvModExponent()
const exponent = T.getInvModExponent()
bench("Inversion via exponentiation p-2 (Little Fermat)", T, iters):
var r = x
r.powUnsafeExponent(exponent)
Expand Down
9 changes: 7 additions & 2 deletions constantine.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ const testDesc: seq[tuple[path: string, useGMP: bool]] = @[
("tests/t_pairing_bls12_381_optate.nim", false),

# Hashing vs OpenSSL
("tests/t_hash_sha256_vs_openssl.nim", true),
# ----------------------------------------------------------
("tests/t_hash_sha256_vs_openssl.nim", true), # skip OpenSSL tests on Windows

# Prime order fields
# ----------------------------------------------------------
("tests/t_fr.nim", false),
]

# For temporary (hopefully) investigation that can only be reproduced in CI
Expand Down Expand Up @@ -264,7 +269,7 @@ proc buildAllBenches() =
buildBench("bench_pairing_bn254_snarks")
buildBench("bench_sha256")
echo "All benchmarks compile successfully."

# Tasks
# ----------------------------------------------------------------

Expand Down
Loading

0 comments on commit 638cb71

Please sign in to comment.