Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Nov 12, 2024
1 parent 8c28605 commit b17028f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions yarn-project/circuits.js/src/contract/artifact_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ export function computeFunctionArtifactHash(
| (Pick<FunctionArtifact, 'bytecode'> & { 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) {
return sha256Fr(Buffer.from(JSON.stringify(fn.returnTypes), 'utf8'));
return sortAndHashArtifactMetadata(fn.returnTypes);
}

function getLogger() {
Expand Down

0 comments on commit b17028f

Please sign in to comment.