From b0005982cf4f20a412c8c98601afb4a7b094069b Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:59:55 +0100 Subject: [PATCH] chore: use `mod.nr` files in stdlib (#5379) # Description ## Problem\* Followup to #5039 ## Summary\* This PR pushes all `hash.nr` into the `hash` directory as a `mod.nr` file, etc. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- .../cryptographic_primitives/ec_primitives.md | 4 ++-- .../cryptographic_primitives/hashes.mdx | 12 ++++++------ .../src/{collections.nr => collections/mod.nr} | 0 noir_stdlib/src/ec/{consts.nr => consts/mod.nr} | 0 noir_stdlib/src/{ec.nr => ec/mod.nr} | 0 noir_stdlib/src/{field.nr => field/mod.nr} | 0 noir_stdlib/src/{hash.nr => hash/mod.nr} | 0 .../src/hash/{poseidon.nr => poseidon/mod.nr} | 0 noir_stdlib/src/{meta.nr => meta/mod.nr} | 0 noir_stdlib/src/{ops.nr => ops/mod.nr} | 0 10 files changed, 8 insertions(+), 8 deletions(-) rename noir_stdlib/src/{collections.nr => collections/mod.nr} (100%) rename noir_stdlib/src/ec/{consts.nr => consts/mod.nr} (100%) rename noir_stdlib/src/{ec.nr => ec/mod.nr} (100%) rename noir_stdlib/src/{field.nr => field/mod.nr} (100%) rename noir_stdlib/src/{hash.nr => hash/mod.nr} (100%) rename noir_stdlib/src/hash/{poseidon.nr => poseidon/mod.nr} (100%) rename noir_stdlib/src/{meta.nr => meta/mod.nr} (100%) rename noir_stdlib/src/{ops.nr => ops/mod.nr} (100%) diff --git a/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md b/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md index f839b4a228e..f262d8160d6 100644 --- a/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md +++ b/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md @@ -18,7 +18,7 @@ curve you want to use, which would be specified using any one of the methods `std::ec::{tecurve,montcurve,swcurve}::{affine,curvegroup}::new` which take the coefficients in the defining equation together with a generator point as parameters. You can find more detail in the comments in -[`noir_stdlib/src/ec.nr`](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec.nr), but +[`noir_stdlib/src/ec/mod.nr`](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/mod.nr), but the gist of it is that the elliptic curves of interest are usually expressed in one of the standard forms implemented here (Twisted Edwards, Montgomery and Short Weierstraß), and in addition to that, you could choose to use `affine` coordinates (Cartesian coordinates - the usual (x,y) - possibly @@ -67,7 +67,7 @@ does indeed lie on `c` by calling `c.contains(p1)`. the curve configurations, the SWU map-to-curve method may be called as `c.swu_map(z,n)`, where `z: Field` depends on `Field` and `c` and must be chosen by the user (the conditions it needs to satisfy are specified in the comments - [here](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec.nr)). + [here](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ec/mod.nr)). ## Examples diff --git a/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx b/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx index efa52b2c3f2..05a2bb983a1 100644 --- a/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx +++ b/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx @@ -15,7 +15,7 @@ import BlackBoxInfo from '@site/src/components/Notes/_blackbox.mdx'; Given an array of bytes, returns the resulting sha256 hash. Specify a message_size to hash only the first `message_size` bytes of the input. -#include_code sha256 noir_stdlib/src/hash.nr rust +#include_code sha256 noir_stdlib/src/hash/mod.nr rust example: #include_code sha256_var test_programs/execution_success/sha256/src/main.nr rust @@ -34,7 +34,7 @@ fn main() { Given an array of bytes, returns an array with the Blake2 hash -#include_code blake2s noir_stdlib/src/hash.nr rust +#include_code blake2s noir_stdlib/src/hash/mod.nr rust example: @@ -51,7 +51,7 @@ fn main() { Given an array of bytes, returns an array with the Blake3 hash -#include_code blake3 noir_stdlib/src/hash.nr rust +#include_code blake3 noir_stdlib/src/hash/mod.nr rust example: @@ -68,7 +68,7 @@ fn main() { Given an array of Fields, returns the Pedersen hash. -#include_code pedersen_hash noir_stdlib/src/hash.nr rust +#include_code pedersen_hash noir_stdlib/src/hash/mod.nr rust example: @@ -80,7 +80,7 @@ example: Given an array of Fields, returns the Pedersen commitment. -#include_code pedersen_commitment noir_stdlib/src/hash.nr rust +#include_code pedersen_commitment noir_stdlib/src/hash/mod.nr rust example: @@ -94,7 +94,7 @@ Given an array of bytes (`u8`), returns the resulting keccak hash as an array of 32 bytes (`[u8; 32]`). Specify a message_size to hash only the first `message_size` bytes of the input. -#include_code keccak256 noir_stdlib/src/hash.nr rust +#include_code keccak256 noir_stdlib/src/hash/mod.nr rust example: diff --git a/noir_stdlib/src/collections.nr b/noir_stdlib/src/collections/mod.nr similarity index 100% rename from noir_stdlib/src/collections.nr rename to noir_stdlib/src/collections/mod.nr diff --git a/noir_stdlib/src/ec/consts.nr b/noir_stdlib/src/ec/consts/mod.nr similarity index 100% rename from noir_stdlib/src/ec/consts.nr rename to noir_stdlib/src/ec/consts/mod.nr diff --git a/noir_stdlib/src/ec.nr b/noir_stdlib/src/ec/mod.nr similarity index 100% rename from noir_stdlib/src/ec.nr rename to noir_stdlib/src/ec/mod.nr diff --git a/noir_stdlib/src/field.nr b/noir_stdlib/src/field/mod.nr similarity index 100% rename from noir_stdlib/src/field.nr rename to noir_stdlib/src/field/mod.nr diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash/mod.nr similarity index 100% rename from noir_stdlib/src/hash.nr rename to noir_stdlib/src/hash/mod.nr diff --git a/noir_stdlib/src/hash/poseidon.nr b/noir_stdlib/src/hash/poseidon/mod.nr similarity index 100% rename from noir_stdlib/src/hash/poseidon.nr rename to noir_stdlib/src/hash/poseidon/mod.nr diff --git a/noir_stdlib/src/meta.nr b/noir_stdlib/src/meta/mod.nr similarity index 100% rename from noir_stdlib/src/meta.nr rename to noir_stdlib/src/meta/mod.nr diff --git a/noir_stdlib/src/ops.nr b/noir_stdlib/src/ops/mod.nr similarity index 100% rename from noir_stdlib/src/ops.nr rename to noir_stdlib/src/ops/mod.nr