From af0b1d537bfa03a6a0853b5b30923cd00e9aeff1 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 21 Feb 2024 16:43:45 +0000 Subject: [PATCH] WIP --- .../src/abis/public_circuit_public_inputs.nr | 9 ++-- .../public_circuit_public_inputs.test.ts.snap | 43 +++++++++++++++++++ .../public_circuit_public_inputs.test.ts | 9 ++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/noir-projects/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr index 6862e3f5e79..87229aecac6 100644 --- a/noir-projects/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/src/crates/types/src/abis/public_circuit_public_inputs.nr @@ -117,7 +117,10 @@ fn serialization_of_empty() { } #[test] -fn hash_smoke() { - let pcpi: PublicCircuitPublicInputs = dep::std::unsafe::zeroed(); - let _hashed = pcpi.hash(); +fn empty_hash() { + let inputs: PublicCircuitPublicInputs = dep::std::unsafe::zeroed(); + let hash = inputs.hash(); + + // Value from public_circuit_public_inputs.test.ts "computes empty item hash" test + assert_eq(hash, 0x0d43290c164ebc3d80d4d17f1939482d9d01ad503cebceb8c665d2bd96597a68); } diff --git a/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap b/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap index 67cd5e64828..87eca1e4dd2 100644 --- a/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/__snapshots__/public_circuit_public_inputs.test.ts.snap @@ -1,5 +1,48 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`PublicCircuitPublicInputs computes empty item hash 1`] = ` +Fr { + "asBigInt": 5998729082391453463848740365500417056769011535294882115251337368669961943656n, + "asBuffer": { + "data": [ + 13, + 67, + 41, + 12, + 22, + 78, + 188, + 61, + 128, + 212, + 209, + 127, + 25, + 57, + 72, + 45, + 157, + 1, + 173, + 80, + 60, + 235, + 206, + 184, + 198, + 101, + 210, + 189, + 150, + 89, + 122, + 104, + ], + "type": "Buffer", + }, +} +`; + exports[`PublicCircuitPublicInputs hash matches snapshot 1`] = ` Fr { "asBigInt": 888846281962498247810067532853731271075966629879817122598695403485138176580n, diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.test.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.test.ts index c72c462f8f0..1030dfec73e 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.test.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.test.ts @@ -28,4 +28,13 @@ describe('PublicCircuitPublicInputs', () => { const hash = target.hash(); expect(hash).toMatchSnapshot(); }); + + it('computes empty item hash', () => { + const item = PublicCircuitPublicInputs.empty(); + const hash = item.hash(); + expect(hash).toMatchSnapshot(); + + // Value used in empty_hash test in public_circuit_public_inputs.nr + // console.log("hash", hash.toString()); + }); });