From f6c50ba8205fbc96f1052ae0ba558ec3c248e0b4 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 09:46:16 +0200 Subject: [PATCH 01/32] make inbreeding a standalone binary crate --- Cargo.toml | 7 ++++--- bins/inbreeding/Cargo.toml | 12 ++++++++++++ .../inbreeding/src}/environment.rs | 0 .../inbreeding/mod.rs => bins/inbreeding/src/main.rs | 0 .../inbreeding => bins/inbreeding/src}/strategy.rs | 0 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 bins/inbreeding/Cargo.toml rename {examples/inbreeding => bins/inbreeding/src}/environment.rs (100%) rename examples/inbreeding/mod.rs => bins/inbreeding/src/main.rs (100%) rename {examples/inbreeding => bins/inbreeding/src}/strategy.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index c30b05a2..78d8fc04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,7 @@ path = "examples/benches/recoding.rs" name = "bench_fec" path = "examples/benches/fec.rs" -[[example]] -name = "inbreeding" -path = "examples/inbreeding/mod.rs" +[workspace] +members = [ + "bins/inbreeding", +] diff --git a/bins/inbreeding/Cargo.toml b/bins/inbreeding/Cargo.toml new file mode 100644 index 00000000..01ef7f61 --- /dev/null +++ b/bins/inbreeding/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "komodo-inbreeding" +version = "0.1.0" +edition = "2021" + +[dependencies] +komodo = { version = "0.2.0", path = "../.." } +ark-pallas = "0.4.0" +clap = { version = "4.5.4", features = ["derive"] } +rand = "0.8.5" +indicatif = "0.17.8" +ark-ff = "0.4.2" diff --git a/examples/inbreeding/environment.rs b/bins/inbreeding/src/environment.rs similarity index 100% rename from examples/inbreeding/environment.rs rename to bins/inbreeding/src/environment.rs diff --git a/examples/inbreeding/mod.rs b/bins/inbreeding/src/main.rs similarity index 100% rename from examples/inbreeding/mod.rs rename to bins/inbreeding/src/main.rs diff --git a/examples/inbreeding/strategy.rs b/bins/inbreeding/src/strategy.rs similarity index 100% rename from examples/inbreeding/strategy.rs rename to bins/inbreeding/src/strategy.rs -- GitLab From d49c9a470fa250e49d176589734c4131d538ff48 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 09:50:27 +0200 Subject: [PATCH 02/32] move inbreeding scripts --- {scripts => bins}/inbreeding/build.nu | 0 {scripts => bins}/inbreeding/mod.nu | 0 {scripts => bins}/inbreeding/plot.nu | 0 {scripts => bins}/inbreeding/run.nu | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {scripts => bins}/inbreeding/build.nu (100%) rename {scripts => bins}/inbreeding/mod.nu (100%) rename {scripts => bins}/inbreeding/plot.nu (100%) rename {scripts => bins}/inbreeding/run.nu (100%) diff --git a/scripts/inbreeding/build.nu b/bins/inbreeding/build.nu similarity index 100% rename from scripts/inbreeding/build.nu rename to bins/inbreeding/build.nu diff --git a/scripts/inbreeding/mod.nu b/bins/inbreeding/mod.nu similarity index 100% rename from scripts/inbreeding/mod.nu rename to bins/inbreeding/mod.nu diff --git a/scripts/inbreeding/plot.nu b/bins/inbreeding/plot.nu similarity index 100% rename from scripts/inbreeding/plot.nu rename to bins/inbreeding/plot.nu diff --git a/scripts/inbreeding/run.nu b/bins/inbreeding/run.nu similarity index 100% rename from scripts/inbreeding/run.nu rename to bins/inbreeding/run.nu -- GitLab From 48cf31ba9b7994291ffba1163a73a3d765ce812e Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 09:50:44 +0200 Subject: [PATCH 03/32] fix inbreeding scripts --- bins/inbreeding/build.nu | 3 ++- bins/inbreeding/plot.nu | 4 ++-- bins/inbreeding/run.nu | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bins/inbreeding/build.nu b/bins/inbreeding/build.nu index d72318a6..75de47de 100644 --- a/bins/inbreeding/build.nu +++ b/bins/inbreeding/build.nu @@ -1,3 +1,4 @@ export def main [] { - cargo build --release --example inbreeding + cd bins/inbreeding + cargo build --release } diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index 4a706353..37522219 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -2,8 +2,8 @@ use std repeat -use ../plot.nu gplt -use ../color.nu * +use ../../scripts/plot.nu gplt +use ../../scripts/color.nu * def "parse strategy" []: string -> record<type: string> { let s = $in diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index 8171f297..73c37a57 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -1,4 +1,4 @@ -const BIN = "./target/release/examples/inbreeding" +const BIN = "./target/release/komodo-inbreeding" const CACHE = ($nu.home-path | path join .cache komodo inbreeding) export def main [ -- GitLab From ee885f67c508c4195013149fefb74dcd5dc025b7 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 09:53:13 +0200 Subject: [PATCH 04/32] remove shebang from `inbreeding plot` it's a module, not a script --- bins/inbreeding/plot.nu | 2 -- 1 file changed, 2 deletions(-) diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index 37522219..713a77ca 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -1,5 +1,3 @@ -#!/usr/bin/env nu - use std repeat use ../../scripts/plot.nu gplt -- GitLab From e122c211be42b299f61221b5b6f38f59b4167f0a Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 09:58:15 +0200 Subject: [PATCH 05/32] move "rng" to `bins/rng/` --- Cargo.toml | 1 + bins/inbreeding/run.nu | 4 ++-- bins/rng/Cargo.toml | 10 ++++++++++ examples/rng.rs => bins/rng/src/main.rs | 0 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 bins/rng/Cargo.toml rename examples/rng.rs => bins/rng/src/main.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 78d8fc04..35a71d66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,4 +87,5 @@ path = "examples/benches/fec.rs" [workspace] members = [ "bins/inbreeding", + "bins/rng", ] diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index 73c37a57..1e430b93 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -38,10 +38,10 @@ export def main [ | $"0x($in)" | into int # compute all the seeds for that strategy, one per scenario - let seeds = cargo run --release --example rng -- ...[ + let seeds = do { cd bins/rng/; cargo run --release -- ...[ -n $options.nb_scenarii --prng-seed $prng_seed - ] + ]} | lines | into int diff --git a/bins/rng/Cargo.toml b/bins/rng/Cargo.toml new file mode 100644 index 00000000..5d34b263 --- /dev/null +++ b/bins/rng/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rng" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.5.4", features = ["derive"] } +rand = "0.8.5" diff --git a/examples/rng.rs b/bins/rng/src/main.rs similarity index 100% rename from examples/rng.rs rename to bins/rng/src/main.rs -- GitLab From f42f27699cd8be4e5988da682ca53cf7d30ebd18 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:01:07 +0200 Subject: [PATCH 06/32] move "rank" to `bins/rank/` --- Cargo.toml | 1 + bins/rank/Cargo.toml | 13 +++++++++++++ examples/rank.rs => bins/rank/src/main.rs | 0 3 files changed, 14 insertions(+) create mode 100644 bins/rank/Cargo.toml rename examples/rank.rs => bins/rank/src/main.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 35a71d66..c8f6fbc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,5 +87,6 @@ path = "examples/benches/fec.rs" [workspace] members = [ "bins/inbreeding", + "bins/rank", "bins/rng", ] diff --git a/bins/rank/Cargo.toml b/bins/rank/Cargo.toml new file mode 100644 index 00000000..a630c8c2 --- /dev/null +++ b/bins/rank/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "rank" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ark-bls12-381 = "0.4.0" +ark-ff = "0.4.2" +ark-std = "0.4.0" +komodo = { version = "0.2.0", path = "../.." } +rand = "0.8.5" diff --git a/examples/rank.rs b/bins/rank/src/main.rs similarity index 100% rename from examples/rank.rs rename to bins/rank/src/main.rs -- GitLab From 02b1d5e75cd119f23867c5a602c49bffae24ddb0 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:03:18 +0200 Subject: [PATCH 07/32] move "curves" to `bins/curves/` --- Cargo.toml | 28 +-------------- bins/curves/Cargo.toml | 35 +++++++++++++++++++ examples/curves.rs => bins/curves/src/main.rs | 2 +- 3 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 bins/curves/Cargo.toml rename examples/curves.rs => bins/curves/src/main.rs (99%) diff --git a/Cargo.toml b/Cargo.toml index c8f6fbc5..4bb06e09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,33 +24,6 @@ rand = "0.8.5" clap = { version = "4.5.4", features = ["derive"] } indicatif = "0.17.8" plnk = { git = "https://gitlab.isae-supaero.fr/a.stevan/plnk", tag = "0.7.0", version = "0.7.0" } -# all the curve dependencies below are used by the `curves` example -ark-bls12-377 = "0.4.0" -ark-bls12-381 = "0.4.0" -ark-bn254 = "0.4.0" -ark-bw6-761 = "0.4.0" -ark-cp6-782 = "0.4.0" -ark-curve25519 = "0.4.0" -ark-ed-on-bls12-377 = "0.4.0" -ark-ed-on-bls12-381 = "0.4.0" -ark-ed-on-bls12-381-bandersnatch = "0.4.0" -ark-ed-on-bn254 = "0.4.0" -ark-ed-on-bw6-761 = "0.4.0" -ark-ed-on-cp6-782 = "0.4.0" -ark-ed-on-mnt4-298 = "0.4.0" -ark-ed-on-mnt4-753 = "0.4.0" -ark-ed25519 = "0.4.0" -ark-mnt4-298 = "0.4.0" -ark-mnt4-753 = "0.4.0" -ark-mnt6-298 = "0.4.0" -ark-mnt6-753 = "0.4.0" -ark-pallas = "0.4.0" -ark-poly-commit = "0.4.0" -ark-secp256k1 = "0.4.0" -ark-secp256r1 = "0.4.0" -ark-secp384r1 = "0.4.0" -ark-secq256k1 = "0.4.0" -ark-vesta = "0.4.0" [[example]] name = "bench_commit" @@ -86,6 +59,7 @@ path = "examples/benches/fec.rs" [workspace] members = [ + "bins/curves", "bins/inbreeding", "bins/rank", "bins/rng", diff --git a/bins/curves/Cargo.toml b/bins/curves/Cargo.toml new file mode 100644 index 00000000..40daf72f --- /dev/null +++ b/bins/curves/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "curves" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ark-bls12-377 = "0.4.0" +ark-bls12-381 = "0.4.0" +ark-bn254 = "0.4.0" +ark-bw6-761 = "0.4.0" +ark-cp6-782 = "0.4.0" +ark-curve25519 = "0.4.0" +ark-ed-on-bls12-377 = "0.4.0" +ark-ed-on-bls12-381 = "0.4.0" +ark-ed-on-bls12-381-bandersnatch = "0.4.0" +ark-ed-on-bn254 = "0.4.0" +ark-ed-on-bw6-761 = "0.4.0" +ark-ed-on-cp6-782 = "0.4.0" +ark-ed-on-mnt4-298 = "0.4.0" +ark-ed-on-mnt4-753 = "0.4.0" +ark-ed25519 = "0.4.0" +ark-ff = "0.4.2" +ark-mnt4-298 = "0.4.0" +ark-mnt4-753 = "0.4.0" +ark-mnt6-298 = "0.4.0" +ark-mnt6-753 = "0.4.0" +ark-pallas = "0.4.0" +ark-poly-commit = "0.4.0" +ark-secp256k1 = "0.4.0" +ark-secp256r1 = "0.4.0" +ark-secp384r1 = "0.4.0" +ark-secq256k1 = "0.4.0" +ark-vesta = "0.4.0" diff --git a/examples/curves.rs b/bins/curves/src/main.rs similarity index 99% rename from examples/curves.rs rename to bins/curves/src/main.rs index 07bbde08..4bd79163 100644 --- a/examples/curves.rs +++ b/bins/curves/src/main.rs @@ -1,6 +1,6 @@ //! example usage of this example code //! ```shell -//! cargo run --example curves +//! cargo run //! | lines //! | parse "{curve}: {fq} -> {fr}" //! | into int fq fr -- GitLab From 0d8f8f444a26ede8e523344136856993fb01f4c4 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:07:51 +0200 Subject: [PATCH 08/32] remove all unused dependencies from `komodo` --- Cargo.toml | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4bb06e09..cf60d57f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,43 +20,6 @@ tracing-subscriber = "0.3.17" ark-bls12-381 = "0.4.0" rand = "0.8.5" -[dev-dependencies] -clap = { version = "4.5.4", features = ["derive"] } -indicatif = "0.17.8" -plnk = { git = "https://gitlab.isae-supaero.fr/a.stevan/plnk", tag = "0.7.0", version = "0.7.0" } - -[[example]] -name = "bench_commit" -path = "examples/benches/commit.rs" - -[[example]] -name = "bench_setup_size" -path = "examples/benches/setup_size.rs" - -[[example]] -name = "bench_field_operations" -path = "examples/benches/operations/field.rs" - -[[example]] -name = "bench_curve_group_operations" -path = "examples/benches/operations/curve_group.rs" - -[[example]] -name = "bench_setup" -path = "examples/benches/setup.rs" - -[[example]] -name = "bench_linalg" -path = "examples/benches/linalg.rs" - -[[example]] -name = "bench_recoding" -path = "examples/benches/recoding.rs" - -[[example]] -name = "bench_fec" -path = "examples/benches/fec.rs" - [workspace] members = [ "bins/curves", -- GitLab From 0e9e1859b0b48ac45a0f64aa4d23de25a727727a Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:13:03 +0200 Subject: [PATCH 09/32] move "example benches" to `benchmarks/` these will be broken for now... --- {examples/benches => benchmarks}/README.md | 0 {examples/benches => benchmarks}/commit.rs | 0 {examples/benches => benchmarks}/fec.rs | 0 {examples/benches => benchmarks}/linalg.rs | 0 {examples/benches => benchmarks}/operations/curve_group.rs | 0 {examples/benches => benchmarks}/operations/field.rs | 0 {examples/benches => benchmarks}/recoding.rs | 0 {examples/benches => benchmarks}/setup.rs | 0 {examples/benches => benchmarks}/setup_size.rs | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {examples/benches => benchmarks}/README.md (100%) rename {examples/benches => benchmarks}/commit.rs (100%) rename {examples/benches => benchmarks}/fec.rs (100%) rename {examples/benches => benchmarks}/linalg.rs (100%) rename {examples/benches => benchmarks}/operations/curve_group.rs (100%) rename {examples/benches => benchmarks}/operations/field.rs (100%) rename {examples/benches => benchmarks}/recoding.rs (100%) rename {examples/benches => benchmarks}/setup.rs (100%) rename {examples/benches => benchmarks}/setup_size.rs (100%) diff --git a/examples/benches/README.md b/benchmarks/README.md similarity index 100% rename from examples/benches/README.md rename to benchmarks/README.md diff --git a/examples/benches/commit.rs b/benchmarks/commit.rs similarity index 100% rename from examples/benches/commit.rs rename to benchmarks/commit.rs diff --git a/examples/benches/fec.rs b/benchmarks/fec.rs similarity index 100% rename from examples/benches/fec.rs rename to benchmarks/fec.rs diff --git a/examples/benches/linalg.rs b/benchmarks/linalg.rs similarity index 100% rename from examples/benches/linalg.rs rename to benchmarks/linalg.rs diff --git a/examples/benches/operations/curve_group.rs b/benchmarks/operations/curve_group.rs similarity index 100% rename from examples/benches/operations/curve_group.rs rename to benchmarks/operations/curve_group.rs diff --git a/examples/benches/operations/field.rs b/benchmarks/operations/field.rs similarity index 100% rename from examples/benches/operations/field.rs rename to benchmarks/operations/field.rs diff --git a/examples/benches/recoding.rs b/benchmarks/recoding.rs similarity index 100% rename from examples/benches/recoding.rs rename to benchmarks/recoding.rs diff --git a/examples/benches/setup.rs b/benchmarks/setup.rs similarity index 100% rename from examples/benches/setup.rs rename to benchmarks/setup.rs diff --git a/examples/benches/setup_size.rs b/benchmarks/setup_size.rs similarity index 100% rename from examples/benches/setup_size.rs rename to benchmarks/setup_size.rs -- GitLab From f24fa3ba4a0b0d8cf6571ff5b0c1ce51ee51b185 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:15:44 +0200 Subject: [PATCH 10/32] move "benchmark scripts" to `benches/scripts/` this commit also fixes the relative imports --- {scripts => benchmarks/scripts}/commit/plot.nu | 6 +++--- {scripts => benchmarks/scripts}/commit/run.nu | 0 {scripts => benchmarks/scripts}/fec/plot.nu | 8 ++++---- {scripts => benchmarks/scripts}/fec/run.nu | 2 +- {scripts => benchmarks/scripts}/recoding/plot.nu | 8 ++++---- {scripts => benchmarks/scripts}/recoding/run.nu | 2 +- {scripts => benchmarks/scripts}/setup/plot.nu | 6 +++--- {scripts => benchmarks/scripts}/setup/run.nu | 0 8 files changed, 16 insertions(+), 16 deletions(-) rename {scripts => benchmarks/scripts}/commit/plot.nu (86%) rename {scripts => benchmarks/scripts}/commit/run.nu (100%) rename {scripts => benchmarks/scripts}/fec/plot.nu (98%) rename {scripts => benchmarks/scripts}/fec/run.nu (94%) rename {scripts => benchmarks/scripts}/recoding/plot.nu (83%) rename {scripts => benchmarks/scripts}/recoding/run.nu (94%) rename {scripts => benchmarks/scripts}/setup/plot.nu (89%) rename {scripts => benchmarks/scripts}/setup/run.nu (100%) diff --git a/scripts/commit/plot.nu b/benchmarks/scripts/commit/plot.nu similarity index 86% rename from scripts/commit/plot.nu rename to benchmarks/scripts/commit/plot.nu index d89ad560..26407549 100644 --- a/scripts/commit/plot.nu +++ b/benchmarks/scripts/commit/plot.nu @@ -1,6 +1,6 @@ -use ../math.nu * -use ../fs.nu check-file -use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] +use ../../../scripts/math.nu * +use ../../../scripts/fs.nu check-file +use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/scripts/commit/run.nu b/benchmarks/scripts/commit/run.nu similarity index 100% rename from scripts/commit/run.nu rename to benchmarks/scripts/commit/run.nu diff --git a/scripts/fec/plot.nu b/benchmarks/scripts/fec/plot.nu similarity index 98% rename from scripts/fec/plot.nu rename to benchmarks/scripts/fec/plot.nu index e8b90bdf..6f037642 100644 --- a/scripts/fec/plot.nu +++ b/benchmarks/scripts/fec/plot.nu @@ -1,7 +1,7 @@ -use ../math.nu * -use ../plot.nu [ into-axis-options, COMMON_OPTIONS ] -use ../fs.nu check-file -use ../plot.nu gplt +use ../../../scripts/math.nu * +use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS ] +use ../../../scripts/fs.nu check-file +use ../../../scripts/plot.nu gplt export def encoding [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/scripts/fec/run.nu b/benchmarks/scripts/fec/run.nu similarity index 94% rename from scripts/fec/run.nu rename to benchmarks/scripts/fec/run.nu index a905ac89..f52193ce 100644 --- a/scripts/fec/run.nu +++ b/benchmarks/scripts/fec/run.nu @@ -1,4 +1,4 @@ -use ../formats.nu * +use ../../../scripts/formats.nu * export def main [ --output: path = "./fec.ndjson", diff --git a/scripts/recoding/plot.nu b/benchmarks/scripts/recoding/plot.nu similarity index 83% rename from scripts/recoding/plot.nu rename to benchmarks/scripts/recoding/plot.nu index c803fcd4..a91c2252 100644 --- a/scripts/recoding/plot.nu +++ b/benchmarks/scripts/recoding/plot.nu @@ -1,7 +1,7 @@ -use ../math.nu * -use ../plot.nu [ into-axis-options, COMMON_OPTIONS ] -use ../fs.nu check-file -use ../plot.nu gplt +use ../../../scripts/math.nu * +use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS ] +use ../../../scripts/fs.nu check-file +use ../../../scripts/plot.nu gplt export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/scripts/recoding/run.nu b/benchmarks/scripts/recoding/run.nu similarity index 94% rename from scripts/recoding/run.nu rename to benchmarks/scripts/recoding/run.nu index a983ef9e..f867bd86 100644 --- a/scripts/recoding/run.nu +++ b/benchmarks/scripts/recoding/run.nu @@ -1,4 +1,4 @@ -use ../formats.nu * +use ../../../scripts/formats.nu * export def main [ --output: path = "./recoding.ndjson", diff --git a/scripts/setup/plot.nu b/benchmarks/scripts/setup/plot.nu similarity index 89% rename from scripts/setup/plot.nu rename to benchmarks/scripts/setup/plot.nu index a6baeeba..2580aa5f 100644 --- a/scripts/setup/plot.nu +++ b/benchmarks/scripts/setup/plot.nu @@ -1,6 +1,6 @@ -use ../math.nu * -use ../fs.nu check-file -use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] +use ../../../scripts/math.nu * +use ../../../scripts/fs.nu check-file +use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/scripts/setup/run.nu b/benchmarks/scripts/setup/run.nu similarity index 100% rename from scripts/setup/run.nu rename to benchmarks/scripts/setup/run.nu -- GitLab From 3e1e432e899a4bdd3b32e218206d9505e8ccafef Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:18:26 +0200 Subject: [PATCH 11/32] move Nushell modules to `.nushell` this commit fixes all relative imports. --- {scripts => .nushell}/color.nu | 0 {scripts => .nushell}/formats.nu | 0 {scripts => .nushell}/fs.nu | 0 {scripts => .nushell}/math.nu | 0 {scripts => .nushell}/parse.nu | 0 {scripts => .nushell}/plot.nu | 0 {scripts => .nushell}/venv.nu | 0 benchmarks/scripts/commit/plot.nu | 6 +++--- benchmarks/scripts/fec/plot.nu | 8 ++++---- benchmarks/scripts/fec/run.nu | 2 +- benchmarks/scripts/recoding/plot.nu | 8 ++++---- benchmarks/scripts/recoding/run.nu | 2 +- benchmarks/scripts/setup/plot.nu | 6 +++--- bins/inbreeding/plot.nu | 4 ++-- 14 files changed, 18 insertions(+), 18 deletions(-) rename {scripts => .nushell}/color.nu (100%) rename {scripts => .nushell}/formats.nu (100%) rename {scripts => .nushell}/fs.nu (100%) rename {scripts => .nushell}/math.nu (100%) rename {scripts => .nushell}/parse.nu (100%) rename {scripts => .nushell}/plot.nu (100%) rename {scripts => .nushell}/venv.nu (100%) diff --git a/scripts/color.nu b/.nushell/color.nu similarity index 100% rename from scripts/color.nu rename to .nushell/color.nu diff --git a/scripts/formats.nu b/.nushell/formats.nu similarity index 100% rename from scripts/formats.nu rename to .nushell/formats.nu diff --git a/scripts/fs.nu b/.nushell/fs.nu similarity index 100% rename from scripts/fs.nu rename to .nushell/fs.nu diff --git a/scripts/math.nu b/.nushell/math.nu similarity index 100% rename from scripts/math.nu rename to .nushell/math.nu diff --git a/scripts/parse.nu b/.nushell/parse.nu similarity index 100% rename from scripts/parse.nu rename to .nushell/parse.nu diff --git a/scripts/plot.nu b/.nushell/plot.nu similarity index 100% rename from scripts/plot.nu rename to .nushell/plot.nu diff --git a/scripts/venv.nu b/.nushell/venv.nu similarity index 100% rename from scripts/venv.nu rename to .nushell/venv.nu diff --git a/benchmarks/scripts/commit/plot.nu b/benchmarks/scripts/commit/plot.nu index 26407549..c0b9e95b 100644 --- a/benchmarks/scripts/commit/plot.nu +++ b/benchmarks/scripts/commit/plot.nu @@ -1,6 +1,6 @@ -use ../../../scripts/math.nu * -use ../../../scripts/fs.nu check-file -use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] +use ../../../.nushell/math.nu * +use ../../../.nushell/fs.nu check-file +use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/benchmarks/scripts/fec/plot.nu b/benchmarks/scripts/fec/plot.nu index 6f037642..1d6efeb6 100644 --- a/benchmarks/scripts/fec/plot.nu +++ b/benchmarks/scripts/fec/plot.nu @@ -1,7 +1,7 @@ -use ../../../scripts/math.nu * -use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS ] -use ../../../scripts/fs.nu check-file -use ../../../scripts/plot.nu gplt +use ../../../.nushell/math.nu * +use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS ] +use ../../../.nushell/fs.nu check-file +use ../../../.nushell/plot.nu gplt export def encoding [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/benchmarks/scripts/fec/run.nu b/benchmarks/scripts/fec/run.nu index f52193ce..f45cbeab 100644 --- a/benchmarks/scripts/fec/run.nu +++ b/benchmarks/scripts/fec/run.nu @@ -1,4 +1,4 @@ -use ../../../scripts/formats.nu * +use ../../../.nushell/formats.nu * export def main [ --output: path = "./fec.ndjson", diff --git a/benchmarks/scripts/recoding/plot.nu b/benchmarks/scripts/recoding/plot.nu index a91c2252..64657f1a 100644 --- a/benchmarks/scripts/recoding/plot.nu +++ b/benchmarks/scripts/recoding/plot.nu @@ -1,7 +1,7 @@ -use ../../../scripts/math.nu * -use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS ] -use ../../../scripts/fs.nu check-file -use ../../../scripts/plot.nu gplt +use ../../../.nushell/math.nu * +use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS ] +use ../../../.nushell/fs.nu check-file +use ../../../.nushell/plot.nu gplt export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/benchmarks/scripts/recoding/run.nu b/benchmarks/scripts/recoding/run.nu index f867bd86..d0209019 100644 --- a/benchmarks/scripts/recoding/run.nu +++ b/benchmarks/scripts/recoding/run.nu @@ -1,4 +1,4 @@ -use ../../../scripts/formats.nu * +use ../../../.nushell/formats.nu * export def main [ --output: path = "./recoding.ndjson", diff --git a/benchmarks/scripts/setup/plot.nu b/benchmarks/scripts/setup/plot.nu index 2580aa5f..c2ce80e4 100644 --- a/benchmarks/scripts/setup/plot.nu +++ b/benchmarks/scripts/setup/plot.nu @@ -1,6 +1,6 @@ -use ../../../scripts/math.nu * -use ../../../scripts/fs.nu check-file -use ../../../scripts/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] +use ../../../.nushell/math.nu * +use ../../../.nushell/fs.nu check-file +use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { check-file $data --span (metadata $data).span diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index 713a77ca..a168f986 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -1,7 +1,7 @@ use std repeat -use ../../scripts/plot.nu gplt -use ../../scripts/color.nu * +use ../../.nushell/plot.nu gplt +use ../../.nushell/color.nu * def "parse strategy" []: string -> record<type: string> { let s = $in -- GitLab From 54ebf127a2af81177468852ba04ff466e95f2124 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:20:27 +0200 Subject: [PATCH 12/32] move "binary module" to `.nushell/` this commit fixes relative imports. --- binary.nu => .nushell/binary.nu | 0 examples/cli.nu | 2 +- komodo.nu | 2 +- tests/binary.nu | 2 +- tests/cli.nu | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename binary.nu => .nushell/binary.nu (100%) diff --git a/binary.nu b/.nushell/binary.nu similarity index 100% rename from binary.nu rename to .nushell/binary.nu diff --git a/examples/cli.nu b/examples/cli.nu index d04bd710..c0cc5c72 100755 --- a/examples/cli.nu +++ b/examples/cli.nu @@ -7,7 +7,7 @@ use ../komodo.nu [ "komodo reconstruct", "komodo ls", ] -use ../binary.nu [ "bytes from_int" ] +use ../.nushell/binary.nu [ "bytes from_int" ] use std assert diff --git a/komodo.nu b/komodo.nu index ef825791..f0addc70 100644 --- a/komodo.nu +++ b/komodo.nu @@ -2,7 +2,7 @@ # # please run `komodo --help` or `komodo <tab>` to have a look at more information -use binary.nu ["bytes from_int"] +use .nushell/binary.nu ["bytes from_int"] const KOMODO_BINARY = "./target/release/komodo" const DEFAULT_LOG_LEVEL = "INFO" diff --git a/tests/binary.nu b/tests/binary.nu index 93988a20..8f45732e 100644 --- a/tests/binary.nu +++ b/tests/binary.nu @@ -1,4 +1,4 @@ -use ../binary.nu [ +use ../.nushell/binary.nu [ "bytes decode", "bytes encode", "bytes from_int", "bytes to_int" ] diff --git a/tests/cli.nu b/tests/cli.nu index f4ed378b..637fcb8f 100644 --- a/tests/cli.nu +++ b/tests/cli.nu @@ -7,7 +7,7 @@ use ../komodo.nu [ "komodo ls", "komodo clean", ] -use ../binary.nu [ "bytes from_int" ] +use ../.nushell/binary.nu [ "bytes from_int" ] use std assert -- GitLab From 6073e76f4a7efbc1dd0245976881a3ff105d53a9 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:25:48 +0200 Subject: [PATCH 13/32] move "inbreeding" docs to README and update --- bins/inbreeding/README.md | 34 ++++++++++++++++++++++++++++++++++ bins/inbreeding/src/main.rs | 32 -------------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 bins/inbreeding/README.md diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md new file mode 100644 index 00000000..fc29f690 --- /dev/null +++ b/bins/inbreeding/README.md @@ -0,0 +1,34 @@ +- build the example for best performance with [`./build.nu`] +- run the experiment with [`./run.nu`] +- plot the results with [`./plot.nu`] + +# Example +```bash +use ./bins/inbreeding + +const PRNG_SEED = 123 +const OPTS = { + nb_bytes: (10 * 1_024), + k: 10, + n: 20, + nb_measurements: 10, + nb_scenarii: 100, + measurement_schedule: 1, + measurement_schedule_start: 0, + max_t: 150, + strategies: [ + "single:1", + "double:0.5:1:2", + "single:2" + "double:0.5:2:3", + "single:3" + "single:5", + "single:10", + ], + environment: "fixed:0", +} + +inbreeding build +inbreeding run --options $OPTS --prng-seed $PRNG_SEED +# inbreeding plot data/inbreeding.nuon --options { k: $opts.k } +``` diff --git a/bins/inbreeding/src/main.rs b/bins/inbreeding/src/main.rs index 730e8f24..71beb012 100644 --- a/bins/inbreeding/src/main.rs +++ b/bins/inbreeding/src/main.rs @@ -1,35 +1,3 @@ -/// - build the example for best performance with [`./../../scripts/inbreeding/build.nu`] -/// - run the experiment with [`./../../scripts/inbreeding/run.nu`] -/// - plot the results with [`./../../scripts/inbreeding/plot.nu`] -/// -/// # Example -/// ```nushell -/// use ./scripts/inbreeding -/// -/// let opts = { -/// nb_bytes: (10 * 1_024), -/// k: 10, -/// n: 20, -/// nb_measurements: 10, -/// nb_scenarii: 100, -/// measurement_schedule: 1, -/// max_t: 150, -/// strategies: [ -/// "single:1", -/// "double:0.5:1:2", -/// "single:2" -/// "double:0.5:2:3", -/// "single:3" -/// "single:5", -/// "single:10", -/// ], -/// environment: "fixed:0", -/// } -/// -/// inbreeding build -/// inbreeding run --output data/inbreeding.nuon --options $opts -/// inbreeding plot data/inbreeding.nuon --options { k: $opts.k } -/// ``` use std::process::exit; use ark_ff::PrimeField; -- GitLab From a2a2862b231b6a77a19523708aa0eda6a168c61c Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:29:40 +0200 Subject: [PATCH 14/32] fix links in "inbreeding" doc --- bins/inbreeding/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md index fc29f690..1c5e43ac 100644 --- a/bins/inbreeding/README.md +++ b/bins/inbreeding/README.md @@ -1,6 +1,6 @@ -- build the example for best performance with [`./build.nu`] -- run the experiment with [`./run.nu`] -- plot the results with [`./plot.nu`] +- build the example for best performance with [`inbreeding build`](./build.nu) +- run the experiment with [`inbreeding run`](./run.nu) +- plot the results with [`inbreeding plot`](./plot.nu) # Example ```bash -- GitLab From 7a2c1c8173f56ba6025fa1aeaca32be181ebb546 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:30:17 +0200 Subject: [PATCH 15/32] split commands in "inbreeding" doc --- bins/inbreeding/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md index 1c5e43ac..138366dd 100644 --- a/bins/inbreeding/README.md +++ b/bins/inbreeding/README.md @@ -5,7 +5,8 @@ # Example ```bash use ./bins/inbreeding - +``` +```bash const PRNG_SEED = 123 const OPTS = { nb_bytes: (10 * 1_024), @@ -27,8 +28,11 @@ const OPTS = { ], environment: "fixed:0", } - +``` +```bash inbreeding build +``` +```bash inbreeding run --options $OPTS --prng-seed $PRNG_SEED # inbreeding plot data/inbreeding.nuon --options { k: $opts.k } ``` -- GitLab From 4e572b60f814ecad18b9646fa9b429e13cf88b73 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 10:53:23 +0200 Subject: [PATCH 16/32] fix "inbreeding plot" --- bins/inbreeding/plot.nu | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index a168f986..57c2ae1b 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -39,9 +39,30 @@ def get-color []: int -> string { } export def main [data: path, --save: path, --options: record<k: int>] { - let data = open $data + let data = $data + | path join '*' + | into glob + | ls $in + | insert strategy { get name | path split | last } + | select name strategy + | insert diversity { + ls $in.name + | each { get name | open | lines } + | flatten + | parse "{x}, {y}" + | into float y + | group-by x --to-table + | update items { get y | math avg } + | rename --column { group: "x", items: "y" } + | into int x # NOTE: $.x needs to be converted to int here because + # `group-by --to-table` converts the grouping key to + # string + } + | reject name let l = $data.diversity.0 | length + print $data + $data | update strategy { parse strategy } | insert sort {|it| -- GitLab From 793fe2edf48bdf60d974b87b02bcef36422a87d0 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 11:00:25 +0200 Subject: [PATCH 17/32] autocomplete experiment names and update plot command --- bins/inbreeding/README.md | 2 +- bins/inbreeding/plot.nu | 23 ++++++++++++++++++----- bins/inbreeding/run.nu | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md index 138366dd..08111b35 100644 --- a/bins/inbreeding/README.md +++ b/bins/inbreeding/README.md @@ -34,5 +34,5 @@ inbreeding build ``` ```bash inbreeding run --options $OPTS --prng-seed $PRNG_SEED -# inbreeding plot data/inbreeding.nuon --options { k: $opts.k } +inbreeding plot ... --options { k: $OPTS.K } ``` diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index 57c2ae1b..1eaca32c 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -1,5 +1,6 @@ use std repeat +use run.nu CACHE use ../../.nushell/plot.nu gplt use ../../.nushell/color.nu * @@ -38,9 +39,23 @@ def get-color []: int -> string { } } -export def main [data: path, --save: path, --options: record<k: int>] { - let data = $data - | path join '*' +def get-experiments []: nothing -> list<string> { + $CACHE + | path join '*' '*' '*' + | into glob + | ls $in + | get name + | path split + | each { last 3 | str join "-" } +} + +export def main [ + experiment: string@get-experiments, # something of the form '<seed>-<timestamp>-<env>' + --save: path, + --options: record<k: int> +] { + let data = [$CACHE, ($experiment | str replace --all '-' (char path_sep)), '*' ] + | path join | into glob | ls $in | insert strategy { get name | path split | last } @@ -61,8 +76,6 @@ export def main [data: path, --save: path, --options: record<k: int>] { | reject name let l = $data.diversity.0 | length - print $data - $data | update strategy { parse strategy } | insert sort {|it| diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index 1e430b93..68be4935 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -1,5 +1,5 @@ const BIN = "./target/release/komodo-inbreeding" -const CACHE = ($nu.home-path | path join .cache komodo inbreeding) +export const CACHE = ($nu.home-path | path join .cache komodo inbreeding) export def main [ --options: record< -- GitLab From ca1db9446f95b055485b827ff1daae9375025e56 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 11:02:25 +0200 Subject: [PATCH 18/32] refactor "inbreeding" constants in `consts.nu` --- bins/inbreeding/consts.nu | 2 ++ bins/inbreeding/plot.nu | 6 +++--- bins/inbreeding/run.nu | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 bins/inbreeding/consts.nu diff --git a/bins/inbreeding/consts.nu b/bins/inbreeding/consts.nu new file mode 100644 index 00000000..7893c29e --- /dev/null +++ b/bins/inbreeding/consts.nu @@ -0,0 +1,2 @@ +export const BIN = "./target/release/komodo-inbreeding" +export const CACHE = ($nu.home-path | path join .cache komodo inbreeding) diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu index 1eaca32c..ec82be62 100644 --- a/bins/inbreeding/plot.nu +++ b/bins/inbreeding/plot.nu @@ -1,6 +1,6 @@ use std repeat -use run.nu CACHE +use consts.nu use ../../.nushell/plot.nu gplt use ../../.nushell/color.nu * @@ -40,7 +40,7 @@ def get-color []: int -> string { } def get-experiments []: nothing -> list<string> { - $CACHE + $consts.CACHE | path join '*' '*' '*' | into glob | ls $in @@ -54,7 +54,7 @@ export def main [ --save: path, --options: record<k: int> ] { - let data = [$CACHE, ($experiment | str replace --all '-' (char path_sep)), '*' ] + let data = [$consts.CACHE, ($experiment | str replace --all '-' (char path_sep)), '*' ] | path join | into glob | ls $in diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index 68be4935..13fa1dff 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -1,5 +1,4 @@ -const BIN = "./target/release/komodo-inbreeding" -export const CACHE = ($nu.home-path | path join .cache komodo inbreeding) +use consts.nu export def main [ --options: record< @@ -25,7 +24,7 @@ export def main [ let now = date now | format date "%s%f" for s in $options.strategies { - let output_dir = [ $CACHE, $"($prng_seed)", $now, $options.environment, $"($s)" ] | path join + let output_dir = [ $consts.CACHE, $"($prng_seed)", $now, $options.environment, $"($s)" ] | path join mkdir $output_dir print $"data will be dumped to `($output_dir)`" @@ -48,7 +47,7 @@ export def main [ for i in 1..$options.nb_scenarii { let output = [ $output_dir, $"($i)" ] | path join - ^$BIN ...[ + ^$consts.BIN ...[ $options.nb_bytes, -k $options.k -n $options.n -- GitLab From 8e3d28510a4dfd1d7d6bae9d9782c1e6bc69f73b Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 11:21:24 +0200 Subject: [PATCH 19/32] fix link to "benchmarks" README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd4f411c..4f5f8788 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,4 @@ nu tests/cli.nu ``` ## the benchmarks -see [the `README`](examples/benches/README.md) +see [the `README`](benchmarks/README.md) -- GitLab From 1e28dba9d54a82d3f816803d63d73c8c67990eb4 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 11:43:18 +0200 Subject: [PATCH 20/32] refactor `error throw` in `error.nu` --- .nushell/color.nu | 12 ++---------- .nushell/error.nu | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 .nushell/error.nu diff --git a/.nushell/color.nu b/.nushell/color.nu index b97c134b..54baf954 100644 --- a/.nushell/color.nu +++ b/.nushell/color.nu @@ -1,19 +1,11 @@ +use error.nu "error throw" + export const WHITE = { r: 1.0, g: 1.0, b: 1.0 } export const BLACK = { r: 0.0, g: 0.0, b: 0.0 } export const RED = { r: 1.0, g: 0.0, b: 0.0 } export const GREEN = { r: 0.0, g: 1.0, b: 0.0 } export const BLUE = { r: 0.0, g: 0.0, b: 1.0 } -def "error throw" [err: record<err: string, label: string, span: record<start: int, end: int>>] { - error make { - msg: $"(ansi red_bold)($err.err)(ansi reset)", - label: { - text: $err.label, - span: $err.span, - }, - } -} - export def "color from-floats" [ r: float, g: float, diff --git a/.nushell/error.nu b/.nushell/error.nu new file mode 100644 index 00000000..34e30b9b --- /dev/null +++ b/.nushell/error.nu @@ -0,0 +1,9 @@ +export def "error throw" [err: record<err: string, label: string, span: record<start: int, end: int>>] { + error make { + msg: $"(ansi red_bold)($err.err)(ansi reset)", + label: { + text: $err.label, + span: $err.span, + }, + } +} -- GitLab From c28625cbfd0373474ae5f49857dbe5b8d9855d75 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:01:14 +0200 Subject: [PATCH 21/32] define `cargo bin` in `.nushell/cargo.nu` to run bins --- .nushell/cargo.nu | 51 ++++++++++++++++++++++++++++++++++++++++++ bins/inbreeding/run.nu | 6 ++--- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 .nushell/cargo.nu diff --git a/.nushell/cargo.nu b/.nushell/cargo.nu new file mode 100644 index 00000000..cd790756 --- /dev/null +++ b/.nushell/cargo.nu @@ -0,0 +1,51 @@ +use std log +use error.nu "error throw" + +def get-workspace-bins []: nothing -> table<name: string, toml: path> { + open Cargo.toml + | get workspace.members + | each { path join "Cargo.toml" } + | wrap toml + | insert name { get toml | open | get package.name } +} + +def get-workspace-bin-names []: nothing -> list<string> { + get-workspace-bins | get name +} + +export def --wrapped "cargo bin" [ + bin: string@get-workspace-bin-names, + --debug, + --build, + ...args: string, +] { + let bin_span = (metadata $bin).span + + let bins = get-workspace-bins + let bin = $bins | where name == $bin | into record + + if $build { + if $debug { + cargo build --manifest-path $bin.toml + } else { + cargo build --release --manifest-path $bin.toml + } + } + + let target = if $debug { + "debug" + } else { + "release" + } + + let bin = "target" | path join $target $bin.name + if not ($bin | path exists) { + error throw { + err: "binary not found", + label: "hasn't been compiled, compile it with --build", + span: $bin_span, + } + } + + ^$bin ...$args +} diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index 13fa1dff..920b0a19 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -1,4 +1,5 @@ use consts.nu +use ../../.nushell/cargo.nu "cargo bin" export def main [ --options: record< @@ -37,10 +38,7 @@ export def main [ | $"0x($in)" | into int # compute all the seeds for that strategy, one per scenario - let seeds = do { cd bins/rng/; cargo run --release -- ...[ - -n $options.nb_scenarii - --prng-seed $prng_seed - ]} + let seeds = cargo bin rng ...[ -n $options.nb_scenarii --prng-seed $prng_seed ] | lines | into int -- GitLab From 8736869a5d30a698b5074f2b102a6922bd940753 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:03:24 +0200 Subject: [PATCH 22/32] add some documentation --- .nushell/cargo.nu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.nushell/cargo.nu b/.nushell/cargo.nu index cd790756..98eaa803 100644 --- a/.nushell/cargo.nu +++ b/.nushell/cargo.nu @@ -13,11 +13,12 @@ def get-workspace-bin-names []: nothing -> list<string> { get-workspace-bins | get name } +# run a binary from the workspace export def --wrapped "cargo bin" [ - bin: string@get-workspace-bin-names, - --debug, - --build, - ...args: string, + bin: string@get-workspace-bin-names, # the name of the binary to run, press tab to autocomplete + --debug, # run in debug mode + --build, # build the binary in the specified mode + ...args: string, # arguments to pass to the binary ] { let bin_span = (metadata $bin).span -- GitLab From 7852a15a6c496a277fa2af0e97044730e080db04 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:04:31 +0200 Subject: [PATCH 23/32] add a section about that in the readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 4f5f8788..3c0dadab 100644 --- a/README.md +++ b/README.md @@ -20,5 +20,14 @@ tests for the binary application can also be run with nu tests/cli.nu ``` +## other binaries +Komodo provides a bunch of other binaries that might be interesting of useful to use. + +The easiest is to use the `cargo.nu` Nushell module as follows +```bash +use .nushell/cargo.nu "cargo bin" +help cargo bin +``` + ## the benchmarks see [the `README`](benchmarks/README.md) -- GitLab From 97101a60535fd84055dd95350391b11233d3dcc2 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:05:54 +0200 Subject: [PATCH 24/32] support descriptions in autocomplete of `cargo bin` --- .nushell/cargo.nu | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.nushell/cargo.nu b/.nushell/cargo.nu index 98eaa803..4314a326 100644 --- a/.nushell/cargo.nu +++ b/.nushell/cargo.nu @@ -9,8 +9,11 @@ def get-workspace-bins []: nothing -> table<name: string, toml: path> { | insert name { get toml | open | get package.name } } -def get-workspace-bin-names []: nothing -> list<string> { - get-workspace-bins | get name +def get-workspace-bin-names []: nothing -> table<value: string, description: string> { + get-workspace-bins | each {{ + value: $in.name, + description: ($in.toml | open | get package.description? | default "") + }} } # run a binary from the workspace -- GitLab From a18667c9a4a533c74463bf2c76c777196f3bb588 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:08:33 +0200 Subject: [PATCH 25/32] add $.description to the TOML of all binaries --- bins/curves/Cargo.toml | 1 + bins/inbreeding/Cargo.toml | 1 + bins/rank/Cargo.toml | 1 + bins/rng/Cargo.toml | 1 + 4 files changed, 4 insertions(+) diff --git a/bins/curves/Cargo.toml b/bins/curves/Cargo.toml index 40daf72f..11dbf377 100644 --- a/bins/curves/Cargo.toml +++ b/bins/curves/Cargo.toml @@ -2,6 +2,7 @@ name = "curves" version = "0.1.0" edition = "2021" +description = "Explore Arkworks elliptic curves." # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bins/inbreeding/Cargo.toml b/bins/inbreeding/Cargo.toml index 01ef7f61..591442b5 100644 --- a/bins/inbreeding/Cargo.toml +++ b/bins/inbreeding/Cargo.toml @@ -2,6 +2,7 @@ name = "komodo-inbreeding" version = "0.1.0" edition = "2021" +description = "Study the 'inbreeding' phenomenon in a system supporting 'recoding'." [dependencies] komodo = { version = "0.2.0", path = "../.." } diff --git a/bins/rank/Cargo.toml b/bins/rank/Cargo.toml index a630c8c2..4d504b93 100644 --- a/bins/rank/Cargo.toml +++ b/bins/rank/Cargo.toml @@ -2,6 +2,7 @@ name = "rank" version = "0.1.0" edition = "2021" +description = "Compute the rank of a matrix." # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bins/rng/Cargo.toml b/bins/rng/Cargo.toml index 5d34b263..39f70a07 100644 --- a/bins/rng/Cargo.toml +++ b/bins/rng/Cargo.toml @@ -2,6 +2,7 @@ name = "rng" version = "0.1.0" edition = "2021" +description = "Generate random numbers from a seed." # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -- GitLab From 3b6ab8816f8d5e38bccddab4347db682de420cbc Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:09:54 +0200 Subject: [PATCH 26/32] rename "komodo-inbreeding" to "inbreeding" --- bins/inbreeding/Cargo.toml | 2 +- bins/inbreeding/consts.nu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bins/inbreeding/Cargo.toml b/bins/inbreeding/Cargo.toml index 591442b5..c8982f38 100644 --- a/bins/inbreeding/Cargo.toml +++ b/bins/inbreeding/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "komodo-inbreeding" +name = "inbreeding" version = "0.1.0" edition = "2021" description = "Study the 'inbreeding' phenomenon in a system supporting 'recoding'." diff --git a/bins/inbreeding/consts.nu b/bins/inbreeding/consts.nu index 7893c29e..177d568c 100644 --- a/bins/inbreeding/consts.nu +++ b/bins/inbreeding/consts.nu @@ -1,2 +1,2 @@ -export const BIN = "./target/release/komodo-inbreeding" +export const BIN = "./target/release/inbreeding" export const CACHE = ($nu.home-path | path join .cache komodo inbreeding) -- GitLab From f5d87bb42d10abab97cf106e4177146958aa3b70 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:26:24 +0200 Subject: [PATCH 27/32] move benchmarks to `benchmarks/src/bin/` --- Cargo.toml | 1 + benchmarks/Cargo.toml | 14 ++++++++++++++ benchmarks/{ => src/bin}/commit.rs | 0 benchmarks/{ => src/bin}/fec.rs | 0 benchmarks/{ => src/bin}/linalg.rs | 0 benchmarks/{ => src/bin}/operations/curve_group.rs | 0 benchmarks/{ => src/bin}/operations/field.rs | 0 benchmarks/{ => src/bin}/recoding.rs | 0 benchmarks/{ => src/bin}/setup.rs | 0 benchmarks/{ => src/bin}/setup_size.rs | 0 benchmarks/src/main.rs | 0 11 files changed, 15 insertions(+) create mode 100644 benchmarks/Cargo.toml rename benchmarks/{ => src/bin}/commit.rs (100%) rename benchmarks/{ => src/bin}/fec.rs (100%) rename benchmarks/{ => src/bin}/linalg.rs (100%) rename benchmarks/{ => src/bin}/operations/curve_group.rs (100%) rename benchmarks/{ => src/bin}/operations/field.rs (100%) rename benchmarks/{ => src/bin}/recoding.rs (100%) rename benchmarks/{ => src/bin}/setup.rs (100%) rename benchmarks/{ => src/bin}/setup_size.rs (100%) create mode 100644 benchmarks/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index cf60d57f..e8397915 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ rand = "0.8.5" [workspace] members = [ + "benchmarks", "bins/curves", "bins/inbreeding", "bins/rank", diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml new file mode 100644 index 00000000..7efa2e3c --- /dev/null +++ b/benchmarks/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "benchmarks" +version = "0.1.0" +edition = "2021" + +[dependencies] +ark-bls12-381 = "0.4.0" +ark-bn254 = "0.4.0" +ark-ff = "0.4.2" +ark-pallas = "0.4.0" +clap = { version = "4.5.4", features = ["derive"] } +komodo = { version = "0.2.0", path = ".." } +plnk = { git = "https://gitlab.isae-supaero.fr/a.stevan/plnk", tag = "0.7.0", version = "0.7.0" } +rand = "0.8.5" diff --git a/benchmarks/commit.rs b/benchmarks/src/bin/commit.rs similarity index 100% rename from benchmarks/commit.rs rename to benchmarks/src/bin/commit.rs diff --git a/benchmarks/fec.rs b/benchmarks/src/bin/fec.rs similarity index 100% rename from benchmarks/fec.rs rename to benchmarks/src/bin/fec.rs diff --git a/benchmarks/linalg.rs b/benchmarks/src/bin/linalg.rs similarity index 100% rename from benchmarks/linalg.rs rename to benchmarks/src/bin/linalg.rs diff --git a/benchmarks/operations/curve_group.rs b/benchmarks/src/bin/operations/curve_group.rs similarity index 100% rename from benchmarks/operations/curve_group.rs rename to benchmarks/src/bin/operations/curve_group.rs diff --git a/benchmarks/operations/field.rs b/benchmarks/src/bin/operations/field.rs similarity index 100% rename from benchmarks/operations/field.rs rename to benchmarks/src/bin/operations/field.rs diff --git a/benchmarks/recoding.rs b/benchmarks/src/bin/recoding.rs similarity index 100% rename from benchmarks/recoding.rs rename to benchmarks/src/bin/recoding.rs diff --git a/benchmarks/setup.rs b/benchmarks/src/bin/setup.rs similarity index 100% rename from benchmarks/setup.rs rename to benchmarks/src/bin/setup.rs diff --git a/benchmarks/setup_size.rs b/benchmarks/src/bin/setup_size.rs similarity index 100% rename from benchmarks/setup_size.rs rename to benchmarks/src/bin/setup_size.rs diff --git a/benchmarks/src/main.rs b/benchmarks/src/main.rs new file mode 100644 index 00000000..e69de29b -- GitLab From 778b64e0b61140c95103dbba948d4e0f3c7a49d0 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:27:36 +0200 Subject: [PATCH 28/32] move "benchmark scripts" to `benchmarks/.nushell/` --- .../{scripts => .nushell}/commit/plot.nu | 0 .../{scripts => .nushell}/commit/run.nu | 0 benchmarks/{scripts => .nushell}/fec/plot.nu | 0 benchmarks/{scripts => .nushell}/fec/run.nu | 0 .../{scripts => .nushell}/recoding/plot.nu | 0 .../{scripts => .nushell}/recoding/run.nu | 0 .../{scripts => .nushell}/setup/plot.nu | 0 benchmarks/{scripts => .nushell}/setup/run.nu | 0 benchmarks/README.md | 30 +++++++++---------- 9 files changed, 15 insertions(+), 15 deletions(-) rename benchmarks/{scripts => .nushell}/commit/plot.nu (100%) rename benchmarks/{scripts => .nushell}/commit/run.nu (100%) rename benchmarks/{scripts => .nushell}/fec/plot.nu (100%) rename benchmarks/{scripts => .nushell}/fec/run.nu (100%) rename benchmarks/{scripts => .nushell}/recoding/plot.nu (100%) rename benchmarks/{scripts => .nushell}/recoding/run.nu (100%) rename benchmarks/{scripts => .nushell}/setup/plot.nu (100%) rename benchmarks/{scripts => .nushell}/setup/run.nu (100%) diff --git a/benchmarks/scripts/commit/plot.nu b/benchmarks/.nushell/commit/plot.nu similarity index 100% rename from benchmarks/scripts/commit/plot.nu rename to benchmarks/.nushell/commit/plot.nu diff --git a/benchmarks/scripts/commit/run.nu b/benchmarks/.nushell/commit/run.nu similarity index 100% rename from benchmarks/scripts/commit/run.nu rename to benchmarks/.nushell/commit/run.nu diff --git a/benchmarks/scripts/fec/plot.nu b/benchmarks/.nushell/fec/plot.nu similarity index 100% rename from benchmarks/scripts/fec/plot.nu rename to benchmarks/.nushell/fec/plot.nu diff --git a/benchmarks/scripts/fec/run.nu b/benchmarks/.nushell/fec/run.nu similarity index 100% rename from benchmarks/scripts/fec/run.nu rename to benchmarks/.nushell/fec/run.nu diff --git a/benchmarks/scripts/recoding/plot.nu b/benchmarks/.nushell/recoding/plot.nu similarity index 100% rename from benchmarks/scripts/recoding/plot.nu rename to benchmarks/.nushell/recoding/plot.nu diff --git a/benchmarks/scripts/recoding/run.nu b/benchmarks/.nushell/recoding/run.nu similarity index 100% rename from benchmarks/scripts/recoding/run.nu rename to benchmarks/.nushell/recoding/run.nu diff --git a/benchmarks/scripts/setup/plot.nu b/benchmarks/.nushell/setup/plot.nu similarity index 100% rename from benchmarks/scripts/setup/plot.nu rename to benchmarks/.nushell/setup/plot.nu diff --git a/benchmarks/scripts/setup/run.nu b/benchmarks/.nushell/setup/run.nu similarity index 100% rename from benchmarks/scripts/setup/run.nu rename to benchmarks/.nushell/setup/run.nu diff --git a/benchmarks/README.md b/benchmarks/README.md index e8cb4e5d..4dfeffaf 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -2,8 +2,8 @@ - install [GPLT](https://gitlab.isae-supaero.fr/a.stevan/gplt) ```nushell -use scripts/math.nu * -use scripts/formats.nu * +use .nushell/math.nu * +use .nushell/formats.nu * ``` ## atomic operations @@ -12,7 +12,7 @@ cargo run --release --example bench_field_operations -- --nb-measurements 1000 o cargo run --release --example bench_curve_group_operations -- --nb-measurements 1000 out> curve_group.ndjson ``` ```nushell -use scripts/parse.nu read-atomic-ops +use .nushell/parse.nu read-atomic-ops gplt multi_bar --title "simple field operations" -l "time (in ns)" ( open field.ndjson @@ -77,47 +77,47 @@ for graph in [ ## trusted setup ```nushell -use scripts/setup/run.nu; seq 0 13 | each { 2 ** $in } | run --output setup.ndjson --curves [ bls12381, pallas, bn254 ] +use .nushell/setup/run.nu; seq 0 13 | each { 2 ** $in } | run --output setup.ndjson --curves [ bls12381, pallas, bn254 ] ``` ```nushell -use ./scripts/setup/plot.nu; plot setup.ndjson +use ./.nushell/setup/plot.nu; plot setup.ndjson ``` ## commit ```nushell -use scripts/commit/run.nu; seq 0 13 | each { 2 ** $in } | run --output commit.ndjson --curves [bls12381, pallas, bn254 ] +use .nushell/commit/run.nu; seq 0 13 | each { 2 ** $in } | run --output commit.ndjson --curves [bls12381, pallas, bn254 ] ``` ```nushell -use ./scripts/commit/plot.nu; plot commit.ndjson +use ./.nushell/commit/plot.nu; plot commit.ndjson ``` ## end-to-end benchmarks ### recoding ```nushell -use scripts/recoding/run.nu +use .nushell/recoding/run.nu seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output recoding.ndjson --curves [ bls12381 ] ``` ```nushell -use ./scripts/recoding/plot.nu; plot recoding.ndjson +use ./.nushell/recoding/plot.nu; plot recoding.ndjson ``` ### FEC ```nushell -use scripts/fec/run.nu +use .nushell/fec/run.nu seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output fec.ndjson --curves [ bls12381 ] ``` ```nushell -use ./scripts/fec/plot.nu; plot encoding fec.ndjson -use ./scripts/fec/plot.nu; plot decoding fec.ndjson -use ./scripts/fec/plot.nu; plot e2e fec.ndjson +use ./.nushell/fec/plot.nu; plot encoding fec.ndjson +use ./.nushell/fec/plot.nu; plot decoding fec.ndjson +use ./.nushell/fec/plot.nu; plot e2e fec.ndjson ``` ## combined graph ```nushell -use ./scripts/fec/plot.nu; plot combined fec.ndjson --recoding recoding.ndjson +use ./.nushell/fec/plot.nu; plot combined fec.ndjson --recoding recoding.ndjson ``` ## ratio graph ```nushell -use ./scripts/fec/plot.nu; plot ratio fec.ndjson --recoding recoding.ndjson +use ./.nushell/fec/plot.nu; plot ratio fec.ndjson --recoding recoding.ndjson ``` -- GitLab From c4e1f1a3cc1719a05e4a5b50b87bc4c18bf40447 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:30:26 +0200 Subject: [PATCH 29/32] add missing deps to "benchmarks" --- benchmarks/Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index 7efa2e3c..a0b4e825 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -6,8 +6,16 @@ edition = "2021" [dependencies] ark-bls12-381 = "0.4.0" ark-bn254 = "0.4.0" +ark-ec = "0.4.2" ark-ff = "0.4.2" ark-pallas = "0.4.0" +ark-poly = "0.4.0" +ark-poly-commit = "0.4.0" +ark-serialize = "0.4.0" +ark-secp256k1 = "0.4.0" +ark-secp256r1 = "0.4.0" +ark-std = "0.4.0" +ark-vesta = "0.4.0" clap = { version = "4.5.4", features = ["derive"] } komodo = { version = "0.2.0", path = ".." } plnk = { git = "https://gitlab.isae-supaero.fr/a.stevan/plnk", tag = "0.7.0", version = "0.7.0" } -- GitLab From 1a0abcc0481be65507895d16508d10af0bd281d2 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:37:31 +0200 Subject: [PATCH 30/32] fix Cargo calls in "benchmarks" modules --- benchmarks/.nushell/commit/run.nu | 2 +- benchmarks/.nushell/fec/run.nu | 2 +- benchmarks/.nushell/recoding/run.nu | 2 +- benchmarks/.nushell/setup/run.nu | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmarks/.nushell/commit/run.nu b/benchmarks/.nushell/commit/run.nu index 61712343..dca9727f 100644 --- a/benchmarks/.nushell/commit/run.nu +++ b/benchmarks/.nushell/commit/run.nu @@ -10,7 +10,7 @@ export def main [ return } - cargo run --release --example bench_commit -- ...[ + cargo run --release --package benchmarks --bin commit -- ...[ --nb-measurements $nb_measurements ...$input --curves ...$curves diff --git a/benchmarks/.nushell/fec/run.nu b/benchmarks/.nushell/fec/run.nu index f45cbeab..8eccebec 100644 --- a/benchmarks/.nushell/fec/run.nu +++ b/benchmarks/.nushell/fec/run.nu @@ -16,7 +16,7 @@ export def main [ "" out> $output for k in $ks { - cargo run --release --example bench_fec -- ...[ + cargo run --release --package benchmarks --bin fec -- ...[ --nb-measurements $nb_measurements ...$input --encoding vandermonde diff --git a/benchmarks/.nushell/recoding/run.nu b/benchmarks/.nushell/recoding/run.nu index d0209019..0bd79e73 100644 --- a/benchmarks/.nushell/recoding/run.nu +++ b/benchmarks/.nushell/recoding/run.nu @@ -16,7 +16,7 @@ export def main [ "" out> $output for k in $ks { - cargo run --release --example bench_recoding -- ...[ + cargo run --release --package benchmarks --bin recoding -- ...[ --nb-measurements $nb_measurements ...$input --shards $k diff --git a/benchmarks/.nushell/setup/run.nu b/benchmarks/.nushell/setup/run.nu index 1631551a..50862c3d 100644 --- a/benchmarks/.nushell/setup/run.nu +++ b/benchmarks/.nushell/setup/run.nu @@ -10,7 +10,7 @@ export def main [ return } - cargo run --release --example bench_setup -- ...[ + cargo run --release --package benchmarks --bin setup -- ...[ --nb-measurements $nb_measurements ...$input --curves ...$curves -- GitLab From f959dd1a413352799bc06f6f071f6c14d51973bf Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:38:58 +0200 Subject: [PATCH 31/32] remove useless main for benchmarks" --- benchmarks/src/main.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 benchmarks/src/main.rs diff --git a/benchmarks/src/main.rs b/benchmarks/src/main.rs deleted file mode 100644 index e69de29b..00000000 -- GitLab From 221aae9a0a37dfaa77c78ce28c88c3eeec21caa7 Mon Sep 17 00:00:00 2001 From: "a.stevan" <antoine.stevan@isae-supaero.fr> Date: Tue, 28 May 2024 12:42:05 +0200 Subject: [PATCH 32/32] move doc of "curves" to a README --- bins/curves/README.md | 37 +++++++++++++++++++++++++++++++++++++ bins/curves/src/main.rs | 38 -------------------------------------- 2 files changed, 37 insertions(+), 38 deletions(-) create mode 100644 bins/curves/README.md diff --git a/bins/curves/README.md b/bins/curves/README.md new file mode 100644 index 00000000..6d4da6aa --- /dev/null +++ b/bins/curves/README.md @@ -0,0 +1,37 @@ +```shell +cargo run + | lines + | parse "{curve}: {fq} -> {fr}" + | into int fq fr + | insert x { (1 - $in.fr / $in.fq) * 100 | math round --precision 1 } +``` + +which gives the followin table + +| curve | fq | fr | x | +| -------------------------------- | --- | --- | ---- | +| ark_bls12_377 | 377 | 253 | 32.9 | +| ark_bls12_381 | 381 | 255 | 33.1 | +| ark_bn254 | 254 | 254 | 0 | +| ark_bw6_761 | 761 | 377 | 50.5 | +| ark_cp6_782 | 782 | 377 | 51.8 | +| ark_curve25519 | 255 | 253 | 0.8 | +| ark_ed25519 | 255 | 253 | 0.8 | +| ark_ed_on_bls12_377 | 253 | 251 | 0.8 | +| ark_ed_on_bls12_381 | 255 | 252 | 1.2 | +| ark_ed_on_bls12_381_bandersnatch | 255 | 253 | 0.8 | +| ark_ed_on_bn254 | 254 | 251 | 1.2 | +| ark_ed_on_bw6_761 | 377 | 374 | 0.8 | +| ark_ed_on_cp6_782 | 377 | 374 | 0.8 | +| ark_ed_on_mnt4_298 | 298 | 296 | 0.7 | +| ark_ed_on_mnt4_753 | 753 | 750 | 0.4 | +| ark_mnt4_298 | 298 | 298 | 0 | +| ark_mnt4_753 | 753 | 753 | 0 | +| ark_mnt6_298 | 298 | 298 | 0 | +| ark_mnt6_753 | 753 | 753 | 0 | +| ark_pallas | 255 | 255 | 0 | +| ark_secp256k1 | 256 | 256 | 0 | +| ark_secp256r1 | 256 | 256 | 0 | +| ark_secp384r1 | 384 | 384 | 0 | +| ark_secq256k1 | 256 | 256 | 0 | +| ark_vesta | 255 | 255 | 0 | diff --git a/bins/curves/src/main.rs b/bins/curves/src/main.rs index 4bd79163..037976ed 100644 --- a/bins/curves/src/main.rs +++ b/bins/curves/src/main.rs @@ -1,41 +1,3 @@ -//! example usage of this example code -//! ```shell -//! cargo run -//! | lines -//! | parse "{curve}: {fq} -> {fr}" -//! | into int fq fr -//! | insert x { (1 - $in.fr / $in.fq) * 100 | math round --precision 1 } -//! ``` -//! -//! which gives the followin table -//! -//! | curve | fq | fr | x | -//! | -------------------------------- | --- | --- | ---- | -//! | ark_bls12_377 | 377 | 253 | 32.9 | -//! | ark_bls12_381 | 381 | 255 | 33.1 | -//! | ark_bn254 | 254 | 254 | 0 | -//! | ark_bw6_761 | 761 | 377 | 50.5 | -//! | ark_cp6_782 | 782 | 377 | 51.8 | -//! | ark_curve25519 | 255 | 253 | 0.8 | -//! | ark_ed25519 | 255 | 253 | 0.8 | -//! | ark_ed_on_bls12_377 | 253 | 251 | 0.8 | -//! | ark_ed_on_bls12_381 | 255 | 252 | 1.2 | -//! | ark_ed_on_bls12_381_bandersnatch | 255 | 253 | 0.8 | -//! | ark_ed_on_bn254 | 254 | 251 | 1.2 | -//! | ark_ed_on_bw6_761 | 377 | 374 | 0.8 | -//! | ark_ed_on_cp6_782 | 377 | 374 | 0.8 | -//! | ark_ed_on_mnt4_298 | 298 | 296 | 0.7 | -//! | ark_ed_on_mnt4_753 | 753 | 750 | 0.4 | -//! | ark_mnt4_298 | 298 | 298 | 0 | -//! | ark_mnt4_753 | 753 | 753 | 0 | -//! | ark_mnt6_298 | 298 | 298 | 0 | -//! | ark_mnt6_753 | 753 | 753 | 0 | -//! | ark_pallas | 255 | 255 | 0 | -//! | ark_secp256k1 | 256 | 256 | 0 | -//! | ark_secp256r1 | 256 | 256 | 0 | -//! | ark_secp384r1 | 384 | 384 | 0 | -//! | ark_secq256k1 | 256 | 256 | 0 | -//! | ark_vesta | 255 | 255 | 0 | use ark_ff::PrimeField; fn show_curve<Fr: PrimeField, Fq: PrimeField>(name: &str) { -- GitLab