From d3b634bd8402900d5765eae0b55e6bdd386063fe Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 6 Nov 2024 08:32:10 +0000 Subject: [PATCH] init --- .../circuits.js/src/contract/artifact_hash.test.ts | 4 ++-- yarn-project/circuits.js/src/contract/artifact_hash.ts | 9 ++++----- .../contract/private_function_membership_proof.test.ts | 3 +-- .../unconstrained_function_membership_proof.test.ts | 3 +-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/yarn-project/circuits.js/src/contract/artifact_hash.test.ts b/yarn-project/circuits.js/src/contract/artifact_hash.test.ts index 269da7368e9..f890244e794 100644 --- a/yarn-project/circuits.js/src/contract/artifact_hash.test.ts +++ b/yarn-project/circuits.js/src/contract/artifact_hash.test.ts @@ -30,7 +30,7 @@ describe('ArtifactHash', () => { for (let i = 0; i < 1000; i++) { expect(computeArtifactHash(testArtifact).toString()).toMatchInlineSnapshot( - `"0x28faac60666e51e4c1f46439d154831c5cbef6b10cdae51a25aa41cb4fa50f65"`, + `"0x24f70e42bf3a55d67eea361b7da4a1186a4dfd1f0a5c63dc5a1574a0b1310ce8"`, ); } }); @@ -43,7 +43,7 @@ describe('ArtifactHash', () => { const testArtifact = loadContractArtifact(content); expect(computeArtifactHash(testArtifact).toString()).toMatchInlineSnapshot( - `"0x28faac60666e51e4c1f46439d154831c5cbef6b10cdae51a25aa41cb4fa50f65"`, + `"0x24f70e42bf3a55d67eea361b7da4a1186a4dfd1f0a5c63dc5a1574a0b1310ce8"`, ); }); }); diff --git a/yarn-project/circuits.js/src/contract/artifact_hash.ts b/yarn-project/circuits.js/src/contract/artifact_hash.ts index de23fe9594d..a7bc52ae7ad 100644 --- a/yarn-project/circuits.js/src/contract/artifact_hash.ts +++ b/yarn-project/circuits.js/src/contract/artifact_hash.ts @@ -92,11 +92,10 @@ export function computeFunctionArtifactHash( | (Pick & { functionMetadataHash: Fr; selector: FunctionSelector }), ) { const selector = 'selector' in fn ? fn.selector : FunctionSelector.fromNameAndParameters(fn); - // TODO(#5860): make bytecode part of artifact hash preimage again - // const bytecodeHash = sha256Fr(fn.bytecode).toBuffer(); - // const metadataHash = 'functionMetadataHash' in fn ? fn.functionMetadataHash : computeFunctionMetadataHash(fn); - // return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer(), metadataHash.toBuffer(), bytecodeHash])); - return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer()])); + + const bytecodeHash = sha256Fr(fn.bytecode).toBuffer(); + const metadataHash = 'functionMetadataHash' in fn ? fn.functionMetadataHash : computeFunctionMetadataHash(fn); + return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer(), metadataHash.toBuffer(), bytecodeHash])); } export function computeFunctionMetadataHash(fn: FunctionArtifact) { diff --git a/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts b/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts index 2135967d9d4..3a57e9787b2 100644 --- a/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts +++ b/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts @@ -31,8 +31,7 @@ describe('private_function_membership_proof', () => { expect(isValidPrivateFunctionMembershipProof(fn, contractClass)).toBeTruthy(); }); - // TODO(#5860): Re-enable this test once noir non-determinism is addressed - test.skip.each([ + test.each([ 'artifactTreeSiblingPath', 'artifactMetadataHash', 'functionMetadataHash', diff --git a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts index 57495f78aea..f795c6f29b6 100644 --- a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts +++ b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts @@ -50,8 +50,7 @@ describe('unconstrained_function_membership_proof', () => { expect(isValidUnconstrainedFunctionMembershipProof(fn, contractClass)).toBeTruthy(); }); - // TODO(#5860): Re-enable this test once noir non-determinism is addressed - test.skip.each(['artifactTreeSiblingPath', 'artifactMetadataHash', 'functionMetadataHash'] as const)( + test.each(['artifactTreeSiblingPath', 'artifactMetadataHash', 'functionMetadataHash'] as const)( 'fails proof if %s is mangled', field => { const proof = createUnconstrainedFunctionMembershipProof(selector, artifact);