diff --git a/.github/workflows/recrawler.yml b/.github/workflows/recrawler.yml index 47f042bcd87..ee832e273a1 100644 --- a/.github/workflows/recrawler.yml +++ b/.github/workflows/recrawler.yml @@ -1,22 +1,22 @@ -# name: Algolia Recrawl -# on: -# push: -# branches: [ master ] -# workflow_dispatch: +name: Algolia Recrawl +on: + push: + branches: [ master ] + workflow_dispatch: -# jobs: -# algolia_recrawl: -# name: Algolia Recrawl -# runs-on: ubuntu-latest -# steps: -# - name: Algolia crawler creation and crawl -# uses: algolia/algoliasearch-crawler-github-actions@v1.1.0 -# id: algolia_crawler -# with: -# crawler-user-id: ${{ secrets.CRAWLER_USER_ID }} -# crawler-api-key: ${{ secrets.CRAWLER_API_KEY }} -# algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} -# algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} -# site-url: 'https://noir-lang.org/' -# crawler-name: noir-lang -# override-config: false +jobs: + algolia_recrawl: + name: Algolia Recrawl + runs-on: ubuntu-latest + steps: + - name: Algolia crawler creation and crawl + uses: algolia/algoliasearch-crawler-github-actions@v1.1.0 + id: algolia_crawler + with: + crawler-user-id: ${{ secrets.CRAWLER_USER_ID }} + crawler-api-key: ${{ secrets.CRAWLER_API_KEY }} + algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} + algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} + site-url: 'https://noir-lang.org/' + crawler-name: noir-lang + override-config: false diff --git a/docs/docs/examples/merkle-proof.mdx b/docs/docs/examples/merkle-proof.mdx index 6430780817c..832fb4bb55e 100644 --- a/docs/docs/examples/merkle-proof.mdx +++ b/docs/docs/examples/merkle-proof.mdx @@ -23,7 +23,7 @@ fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Fie The message is hashed using `hash_to_field`. The specific hash function that is being used is chosen by the backend. The only requirement is that this hash function can heuristically be used as a -random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen` +random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen_hash` instead. ```rust diff --git a/docs/docs/index.md b/docs/docs/index.md index 9ebe1d54944..75e1abf2932 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -79,7 +79,8 @@ ACIR Supported OPCODES: - Blake2s - Schnorr signature verification - MerkleMembership -- Pedersen +- Pedersen Commitment +- Pedersen Hash - HashToField ## Libraries diff --git a/docs/docs/standard_library/black_box_fns.md b/docs/docs/standard_library/black_box_fns.md index c758846b688..1dfabfe8f22 100644 --- a/docs/docs/standard_library/black_box_fns.md +++ b/docs/docs/standard_library/black_box_fns.md @@ -29,7 +29,8 @@ Here is a list of the current black box functions that are supported by UltraPlo - [SHA256](./cryptographic_primitives/hashes#sha256) - [Schnorr signature verification](./cryptographic_primitives/schnorr) - [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen](./cryptographic_primitives/hashes#pedersen) +- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) - [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) - [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) - [Fixed base scalar multiplication](./cryptographic_primitives/scalar) diff --git a/docs/docs/standard_library/cryptographic_primitives/00_hashes.mdx b/docs/docs/standard_library/cryptographic_primitives/00_hashes.mdx index 2cc3cd81e4e..b482d9afc65 100644 --- a/docs/docs/standard_library/cryptographic_primitives/00_hashes.mdx +++ b/docs/docs/standard_library/cryptographic_primitives/00_hashes.mdx @@ -47,12 +47,12 @@ fn main() { -## pedersen +## pedersen_hash Given an array of Fields, returns the Pedersen hash. ```rust -fn pedersen(_input : [Field]) -> [Field; 2] +fn pedersen_hash(_input : [Field]) -> Field ``` example: @@ -60,7 +60,28 @@ example: ```rust fn main() { let x = [163, 117, 178, 149]; // some random bytes - let hash = std::hash::pedersen(x); + let hash = std::hash::pedersen_hash(x); +} +``` + + + + + +## pedersen_commitment + +Given an array of Fields, returns the Pedersen commitment. + +```rust +fn pedersen_commitment(_input : [Field]) -> [Field; 2] +``` + +example: + +```rust +fn main() { + let x = [163, 117, 178, 149]; // some random bytes + let commitment = std::hash::pedersen_commitment(x); } ``` diff --git a/docs/docs/standard_library/merkle_trees.md b/docs/docs/standard_library/merkle_trees.md index 9761105f4f2..dc383a1426b 100644 --- a/docs/docs/standard_library/merkle_trees.md +++ b/docs/docs/standard_library/merkle_trees.md @@ -17,7 +17,7 @@ keywords: ## compute_merkle_root -Returns the root of the tree from the provided leaf and its hash path, using a [Pedersen hash](cryptographic_primitives/00_hashes.mdx#pedersen). +Returns the root of the tree from the provided leaf and its hash path, using a [Pedersen hash](cryptographic_primitives/00_hashes.mdx#pedersen_hash). ```rust fn compute_merkle_root(leaf : Field, index : Field, hash_path: [Field]) -> Field diff --git a/noir_stdlib/src/hash.nr b/noir_stdlib/src/hash.nr index 67e01c36e1c..f4a1ec7c599 100644 --- a/noir_stdlib/src/hash.nr +++ b/noir_stdlib/src/hash.nr @@ -6,12 +6,12 @@ pub fn sha256(_input : [u8; N]) -> [u8; 32] {} #[foreign(blake2s)] pub fn blake2s(_input : [u8; N]) -> [u8; 32] {} -pub fn pedersen(input : [Field; N]) -> [Field; 2] { - pedersen_with_separator(input, 0) +pub fn pedersen_commitment(input : [Field; N]) -> [Field; 2] { + pedersen_commitment_with_separator(input, 0) } #[foreign(pedersen)] -pub fn pedersen_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {} +pub fn pedersen_commitment_with_separator(_input : [Field; N], _separator : u32) -> [Field; 2] {} pub fn pedersen_hash(input : [Field; N]) -> Field { pedersen_hash_with_separator(input, 0) diff --git a/noir_stdlib/src/merkle.nr b/noir_stdlib/src/merkle.nr index 0bad55f93f4..02bb54a0315 100644 --- a/noir_stdlib/src/merkle.nr +++ b/noir_stdlib/src/merkle.nr @@ -14,8 +14,8 @@ pub fn compute_merkle_root(leaf: Field, index: Field, hash_path: [Field; N]) } else { (current, hash_path[i]) }; - - current = crate::hash::pedersen([hash_left, hash_right])[0]; + // TODO(Kev): This should be changed to use pedersen_hash + current = crate::hash::pedersen_commitment([hash_left, hash_right])[0]; }; current } diff --git a/tooling/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr b/tooling/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr index aef6a13271b..c07c35d521a 100644 --- a/tooling/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr +++ b/tooling/nargo_cli/tests/compile_success_empty/intrinsic_die/src/main.nr @@ -4,6 +4,6 @@ use dep::std; fn main(x: Field) { let bytes = x.to_be_bytes(32); - let hash = std::hash::pedersen([x]); + let hash = std::hash::pedersen_commitment([x]); let _p1 = std::scalar_mul::fixed_base_embedded_curve(x, 0); } diff --git a/tooling/nargo_cli/tests/execution_success/brillig_pedersen/src/main.nr b/tooling/nargo_cli/tests/execution_success/brillig_pedersen/src/main.nr index 5aecf4fb84e..b7de745a342 100644 --- a/tooling/nargo_cli/tests/execution_success/brillig_pedersen/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/brillig_pedersen/src/main.nr @@ -1,7 +1,7 @@ use dep::std; unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { - let res = std::hash::pedersen_with_separator([x, y], 0); + let res = std::hash::pedersen_commitment_with_separator([x, y], 0); assert(res[0] == out_x); assert(res[1] == out_y); let res_hash = std::hash::pedersen_hash_with_separator([x, y], 0); @@ -15,7 +15,7 @@ unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Fiel state = state * 8 + raw_data[i]; } state += salt; - let hash = std::hash::pedersen_with_separator([state], 0); - assert(std::hash::pedersen_with_separator([43], 0)[0] == hash[0]); + let hash = std::hash::pedersen_commitment_with_separator([state], 0); + assert(std::hash::pedersen_commitment_with_separator([43], 0)[0] == hash[0]); } diff --git a/tooling/nargo_cli/tests/execution_success/eddsa/src/main.nr b/tooling/nargo_cli/tests/execution_success/eddsa/src/main.nr index f82b3224c3d..724ff1a640c 100644 --- a/tooling/nargo_cli/tests/execution_success/eddsa/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/eddsa/src/main.nr @@ -12,9 +12,9 @@ fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { // Manually computed as fields can't use modulo. Importantantly the commitment is within // the subgroup order. Note that choice of hash is flexible for this step. - // let r_a = hash::pedersen([_priv_key_a, msg])[0] % bjj.suborder; // modulus computed manually + // let r_a = hash::pedersen_commitment([_priv_key_a, msg])[0] % bjj.suborder; // modulus computed manually let r_a = 1414770703199880747815475415092878800081323795074043628810774576767372531818; - // let r_b = hash::pedersen([_priv_key_b, msg])[0] % bjj.suborder; // modulus computed manually + // let r_b = hash::pedersen_commitment([_priv_key_b, msg])[0] % bjj.suborder; // modulus computed manually let r_b = 571799555715456644614141527517766533395606396271089506978608487688924659618; let r8_a = bjj.curve.mul(r_a, bjj.base8); diff --git a/tooling/nargo_cli/tests/execution_success/import/src/main.nr b/tooling/nargo_cli/tests/execution_success/import/src/main.nr index cb6476480d8..b85ee74ff69 100644 --- a/tooling/nargo_cli/tests/execution_success/import/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/import/src/main.nr @@ -2,7 +2,7 @@ mod import; use crate::import::hello; fn main(x : Field, y : Field) { - let _k = dep::std::hash::pedersen([x]); + let _k = dep::std::hash::pedersen_commitment([x]); let _l = hello(x); assert(x != import::hello(y)); diff --git a/tooling/nargo_cli/tests/execution_success/pedersen_check/src/main.nr b/tooling/nargo_cli/tests/execution_success/pedersen_check/src/main.nr index e5e8c740ea9..ff4e9539d7e 100644 --- a/tooling/nargo_cli/tests/execution_success/pedersen_check/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/pedersen_check/src/main.nr @@ -1,7 +1,7 @@ use dep::std; fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { - let res = std::hash::pedersen([x, y]); + let res = std::hash::pedersen_commitment([x, y]); assert(res[0] == out_x); assert(res[1] == out_y); let res_hash = std::hash::pedersen_hash_with_separator([x, y], 0); @@ -15,7 +15,7 @@ fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: F state = state * 8 + raw_data[i]; } state += salt; - let hash = std::hash::pedersen([state]); - assert(std::hash::pedersen([43])[0] == hash[0]); + let hash = std::hash::pedersen_commitment([state]); + assert(std::hash::pedersen_commitment([43])[0] == hash[0]); } diff --git a/tooling/nargo_cli/tests/execution_success/simple_shield/src/main.nr b/tooling/nargo_cli/tests/execution_success/simple_shield/src/main.nr index c26a53d56cd..ef6e5dbde12 100644 --- a/tooling/nargo_cli/tests/execution_success/simple_shield/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/simple_shield/src/main.nr @@ -20,13 +20,13 @@ fn main( let pubkey_y = pubkey[1]; // Compute input note commitment - let note_commitment = std::hash::pedersen([pubkey_x, pubkey_y]); + let note_commitment = std::hash::pedersen_commitment([pubkey_x, pubkey_y]); // Compute input note nullifier - let nullifier = std::hash::pedersen([note_commitment[0], index, priv_key]); + let nullifier = std::hash::pedersen_commitment([note_commitment[0], index, priv_key]); // Compute output note nullifier - let receiver_note_commitment = std::hash::pedersen([to_pubkey_x, to_pubkey_y]); + let receiver_note_commitment = std::hash::pedersen_commitment([to_pubkey_x, to_pubkey_y]); // Check that the input note nullifier is in the root assert(note_root == std::merkle::compute_merkle_root(note_commitment[0], index, note_hash_path)); diff --git a/tooling/nargo_cli/tests/execution_success/strings/src/main.nr b/tooling/nargo_cli/tests/execution_success/strings/src/main.nr index 42e8f7967ae..e3b5a5e1197 100644 --- a/tooling/nargo_cli/tests/execution_success/strings/src/main.nr +++ b/tooling/nargo_cli/tests/execution_success/strings/src/main.nr @@ -23,7 +23,7 @@ fn main(message : pub str<11>, y : Field, hex_as_string : str<4>, hex_as_field : std::println(bad_message); assert(message != bad_message); - let hash = std::hash::pedersen([x]); + let hash = std::hash::pedersen_commitment([x]); std::println(hash); assert(hex_as_string == "0x41"); @@ -48,7 +48,7 @@ fn test_prints_array() { std::println(array); - let hash = std::hash::pedersen(array); + let hash = std::hash::pedersen_commitment(array); std::println(hash); } diff --git a/tooling/nargo_cli/tests/noir_test_failure/should_fail_mismatch/src/main.nr b/tooling/nargo_cli/tests/noir_test_failure/should_fail_mismatch/src/main.nr index 923c27d17d1..6c8dbda5149 100644 --- a/tooling/nargo_cli/tests/noir_test_failure/should_fail_mismatch/src/main.nr +++ b/tooling/nargo_cli/tests/noir_test_failure/should_fail_mismatch/src/main.nr @@ -12,5 +12,5 @@ fn test_with_extra_space() { // The assert message has a space #[test(should_fail_with = "Not equal")] fn test_runtime_mismatch() { - assert_eq(dep::std::hash::pedersen([27])[0], 0, "Not equal "); + assert_eq(dep::std::hash::pedersen_commitment([27])[0], 0, "Not equal "); } diff --git a/tooling/nargo_cli/tests/noir_test_success/should_fail_with_matches/src/main.nr b/tooling/nargo_cli/tests/noir_test_success/should_fail_with_matches/src/main.nr index 8ae5e56a463..cbbc2144631 100644 --- a/tooling/nargo_cli/tests/noir_test_success/should_fail_with_matches/src/main.nr +++ b/tooling/nargo_cli/tests/noir_test_success/should_fail_with_matches/src/main.nr @@ -10,10 +10,10 @@ fn test_should_fail_without_match() { #[test(should_fail_with = "Not equal")] fn test_should_fail_with_runtime_match() { - assert_eq(dep::std::hash::pedersen([27])[0], 0, "Not equal"); + assert_eq(dep::std::hash::pedersen_commitment([27])[0], 0, "Not equal"); } #[test(should_fail)] fn test_should_fail_without_runtime_match() { - assert_eq(dep::std::hash::pedersen([27])[0], 0); + assert_eq(dep::std::hash::pedersen_commitment([27])[0], 0); }