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 9d3b351 commit bb6e36d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 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
9 changes: 4 additions & 5 deletions yarn-project/circuits.js/src/contract/artifact_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ 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) {
Expand Down

0 comments on commit bb6e36d

Please sign in to comment.