Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Nov 6, 2024
1 parent 1c9ee45 commit 2f6cd00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
11 changes: 11 additions & 0 deletions noir-projects/noir-contracts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ echo "Compiling contracts..."
NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo}
$NARGO compile --silence-warnings --inliner-aggressiveness 0

protocol_contracts=$(jq -r '.[]' "./protocol_contracts.json")
for contract in $protocol_contracts; do
artifactPath="./target/$contract.json"
readarray -t fnNames < <(jq -r '.functions[] | select(.custom_attributes | index("private")) | .name' "$artifactPath")
readarray -t fnBytecodes < <(jq -r '.functions[] | select(.custom_attributes | index("private")) | .bytecode' "$artifactPath")

for i in "${!fnBytecodes[@]}"; do
echo "${fnNames[$i]}, $(echo -n "${fnBytecodes[$i]}" | sha256sum | awk '{print $1}')"
done
done

echo "Generating protocol contract vks..."
BB_HASH=${BB_HASH:-$(cd ../../ && git ls-tree -r HEAD | grep 'barretenberg/cpp' | awk '{print $3}' | git hash-object --stdin)}
echo Using BB hash $BB_HASH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ contract ContractInstanceDeployer {
}
}

#[private]
fn foo_bar(a: Field) -> Field {
a + 1
}

#[private]
fn deploy(
salt: Field,
Expand Down
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 @@ -134,15 +134,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 sortHashArtifactMetadata(fn.returnTypes);
}

function getLogger() {
Expand Down

0 comments on commit 2f6cd00

Please sign in to comment.