2018-12-01 19:12:05 +00:00
|
|
|
|
packageName = "constantine"
|
2018-07-24 14:52:18 +00:00
|
|
|
|
version = "0.0.1"
|
|
|
|
|
author = "Status Research & Development GmbH"
|
2018-09-05 04:38:34 +00:00
|
|
|
|
description = "This library provides constant time big int primitives."
|
2018-07-24 14:52:18 +00:00
|
|
|
|
license = "MIT or Apache License 2.0"
|
|
|
|
|
srcDir = "src"
|
|
|
|
|
|
|
|
|
|
### Dependencies
|
2020-02-22 15:37:31 +00:00
|
|
|
|
requires "nim >= 1.1.0"
|
2018-07-24 14:52:18 +00:00
|
|
|
|
|
|
|
|
|
### Helper functions
|
2020-03-16 15:33:51 +00:00
|
|
|
|
proc test(flags, path: string) =
|
2018-07-24 14:52:18 +00:00
|
|
|
|
if not dirExists "build":
|
|
|
|
|
mkDir "build"
|
2020-02-23 17:27:26 +00:00
|
|
|
|
# Compilation language is controlled by WEAVE_TEST_LANG
|
|
|
|
|
var lang = "c"
|
|
|
|
|
if existsEnv"TEST_LANG":
|
|
|
|
|
lang = getEnv"TEST_LANG"
|
|
|
|
|
|
2020-03-16 15:33:51 +00:00
|
|
|
|
var cc = ""
|
|
|
|
|
if existsEnv"CC":
|
|
|
|
|
cc = " --cc:" & getEnv"CC"
|
|
|
|
|
|
2020-02-23 17:27:26 +00:00
|
|
|
|
echo "\n========================================================================================"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
echo "Running [flags: ", flags, "] ", path
|
2020-02-23 17:27:26 +00:00
|
|
|
|
echo "========================================================================================"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
exec "nim " & lang & cc & " " & flags & " --verbosity:0 --outdir:build -r --hints:off --warnings:off " & path
|
2018-07-24 14:52:18 +00:00
|
|
|
|
|
|
|
|
|
### tasks
|
|
|
|
|
task test, "Run all tests":
|
2020-02-23 17:27:26 +00:00
|
|
|
|
# -d:testingCurves is configured in a *.nim.cfg for convenience
|
2020-03-17 21:04:37 +00:00
|
|
|
|
|
|
|
|
|
# Primitives
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_primitives.nim"
|
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Big ints
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_io_bigints.nim"
|
|
|
|
|
test "", "tests/test_bigints.nim"
|
|
|
|
|
test "", "tests/test_bigints_multimod.nim"
|
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "", "tests/test_bigints_vs_gmp.nim"
|
|
|
|
|
|
|
|
|
|
# Field
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_io_fields"
|
|
|
|
|
test "", "tests/test_finite_fields.nim"
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "", "tests/test_finite_fields_mulsquare.nim"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_finite_fields_powinv.nim"
|
|
|
|
|
|
|
|
|
|
test "", "tests/test_finite_fields_vs_gmp.nim"
|
2020-02-29 13:49:38 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# 𝔽p2
|
|
|
|
|
test "", "tests/test_fp2.nim"
|
|
|
|
|
|
2020-03-16 15:33:51 +00:00
|
|
|
|
if sizeof(int) == 8: # 32-bit tests
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Primitives
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_primitives.nim"
|
2020-02-29 13:49:38 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Big ints
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_io_bigints.nim"
|
|
|
|
|
test "-d:Constantine32", "tests/test_bigints.nim"
|
|
|
|
|
test "-d:Constantine32", "tests/test_bigints_multimod.nim"
|
2020-02-23 17:27:26 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_bigints_vs_gmp.nim"
|
|
|
|
|
|
|
|
|
|
# Field
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_io_fields"
|
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields.nim"
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields_mulsquare.nim"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields_powinv.nim"
|
|
|
|
|
|
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields_vs_gmp.nim"
|
2020-02-29 13:49:38 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# 𝔽p2
|
|
|
|
|
test "", "tests/test_fp2.nim"
|
|
|
|
|
|
2020-02-23 17:27:26 +00:00
|
|
|
|
task test_no_gmp, "Run tests that don't require GMP":
|
|
|
|
|
# -d:testingCurves is configured in a *.nim.cfg for convenience
|
2020-03-17 21:04:37 +00:00
|
|
|
|
|
|
|
|
|
# Primitives
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_primitives.nim"
|
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Big ints
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_io_bigints.nim"
|
|
|
|
|
test "", "tests/test_bigints.nim"
|
|
|
|
|
test "", "tests/test_bigints_multimod.nim"
|
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Field
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_io_fields"
|
|
|
|
|
test "", "tests/test_finite_fields.nim"
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "", "tests/test_finite_fields_mulsquare.nim"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "", "tests/test_finite_fields_powinv.nim"
|
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# 𝔽p2
|
|
|
|
|
test "", "tests/test_fp2.nim"
|
|
|
|
|
|
2020-03-16 15:33:51 +00:00
|
|
|
|
if sizeof(int) == 8: # 32-bit tests
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Primitives
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_primitives.nim"
|
2020-02-29 13:49:38 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Big ints
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_io_bigints.nim"
|
|
|
|
|
test "-d:Constantine32", "tests/test_bigints.nim"
|
|
|
|
|
test "-d:Constantine32", "tests/test_bigints_multimod.nim"
|
2020-02-29 13:49:38 +00:00
|
|
|
|
|
2020-03-17 21:04:37 +00:00
|
|
|
|
# Field
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_io_fields"
|
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields.nim"
|
2020-03-17 21:04:37 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields_mulsquare.nim"
|
2020-03-16 15:33:51 +00:00
|
|
|
|
test "-d:Constantine32", "tests/test_finite_fields_powinv.nim"
|
2020-03-17 21:04:37 +00:00
|
|
|
|
|
|
|
|
|
# 𝔽p2
|
|
|
|
|
test "", "tests/test_fp2.nim"
|
2020-03-20 22:03:52 +00:00
|
|
|
|
|
|
|
|
|
task bench, "Run benchmark with your default compiler":
|
|
|
|
|
if not dirExists "build":
|
|
|
|
|
mkDir "build"
|
|
|
|
|
exec "nim c -d:danger --verbosity:0 -o:build/bench_finite_fields_default -r --hints:off --warnings:off benchmarks/bench_finite_fields"
|
|
|
|
|
|
|
|
|
|
task bench_gcc, "Run benchmark with gcc":
|
|
|
|
|
if not dirExists "build":
|
|
|
|
|
mkDir "build"
|
|
|
|
|
exec "nim c --cc:gcc -d:danger --verbosity:0 -o:build/bench_finite_fields_gcc -r --hints:off --warnings:off benchmarks/bench_finite_fields"
|
|
|
|
|
|
|
|
|
|
task bench_clang, "Run benchmark with clang":
|
|
|
|
|
if not dirExists "build":
|
|
|
|
|
mkDir "build"
|
|
|
|
|
exec "nim c --cc:clang -d:danger --verbosity:0 -o:build/bench_finite_fields_clang -r --hints:off --warnings:off benchmarks/bench_finite_fields"
|