Skip to content

Commit

Permalink
chore: update example to show how to split public inputs in bash (noi…
Browse files Browse the repository at this point in the history
…r-lang/noir#6472)

fix: Discard optimisation that would change execution ordering or that is related to call outputs (noir-lang/noir#6461)
chore: proptest for `canonicalize` on infix type expressions (noir-lang/noir#6269)
fix: let formatter respect newlines between comments (noir-lang/noir#6458)
fix: check infix expression is valid in program input (noir-lang/noir#6450)
fix: don't crash on AsTraitPath with empty path (noir-lang/noir#6454)
fix(tests): Prevent EOF error while running test programs (noir-lang/noir#6455)
fix(sea): mem2reg to treat block input references as alias (noir-lang/noir#6452)
chore: revamp attributes (noir-lang/noir#6424)
feat!: Always Check Arithmetic Generics at Monomorphization (noir-lang/noir#6329)
chore: split path and import lookups (noir-lang/noir#6430)
fix(ssa): Resolve value IDs in terminator before comparing to array (noir-lang/noir#6448)
fix: right shift is not a regular division (noir-lang/noir#6400)
  • Loading branch information
AztecBot committed Nov 8, 2024
2 parents 173891c + 98f5f3f commit 5a03b89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b8654f700b218cc09c5381af65df11ead9ffcdaf
b74b4eaf7acf6becd0f98ab25d0d5ccde3affebe
13 changes: 9 additions & 4 deletions noir/noir-repo/examples/codegen_verifier/codegen_verifier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ nargo execute witness
PROOF_PATH=./target/proof
$BACKEND prove -b ./target/hello_world.json -w ./target/witness.gz -o $PROOF_PATH

NUM_PUBLIC_INPUTS=1
# Sanity check that proof is valid.
$BACKEND verify -k ./target/vk -p ./target/proof

NUM_PUBLIC_INPUTS=2
PUBLIC_INPUT_BYTES=$((32 * $NUM_PUBLIC_INPUTS))
HEX_PUBLIC_INPUTS=$(head -c $PUBLIC_INPUT_BYTES $PROOF_PATH | od -An -v -t x1 | tr -d $' \n')
HEX_PROOF=$(tail -c +$(($PUBLIC_INPUT_BYTES + 1)) $PROOF_PATH | od -An -v -t x1 | tr -d $' \n')

# Split public inputs into strings where each string represents a `bytes32`.
SPLIT_HEX_PUBLIC_INPUTS=$(sed -e 's/.\{64\}/0x&,/g' <<< $HEX_PUBLIC_INPUTS)

# Spin up an anvil node to deploy the contract to
anvil &

Expand All @@ -31,8 +37,7 @@ DEPLOY_INFO=$(forge create UltraVerifier \
VERIFIER_ADDRESS=$(echo $DEPLOY_INFO | jq -r '.deployedTo')

# Call the verifier contract with our proof.
# Note that we haven't needed to split up `HEX_PUBLIC_INPUTS` as there's only a single public input
cast call $VERIFIER_ADDRESS "verify(bytes, bytes32[])(bool)" "0x$HEX_PROOF" "[0x$HEX_PUBLIC_INPUTS]"
cast call $VERIFIER_ADDRESS "verify(bytes, bytes32[])(bool)" "0x$HEX_PROOF" "[$SPLIT_HEX_PUBLIC_INPUTS]"

# Stop anvil node again
kill %-
kill %-
4 changes: 2 additions & 2 deletions noir/noir-repo/examples/codegen_verifier/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main(x: Field, y: pub Field) {
fn main(x: pub Field, y: pub Field) {
assert(x != y);
}
}

0 comments on commit 5a03b89

Please sign in to comment.