Skip to content

Commit

Permalink
chore: add example script to generate a verifier contract
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed May 10, 2024
1 parent 297779a commit a22d895
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions noir/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ test:
COPY noir-repo/.rustfmt.toml noir-repo/.rustfmt.toml
RUN ./scripts/test_native.sh

examples:
FROM +nargo
ENV PATH="/usr/src/noir-repo/target/release:${PATH}"

COPY --dir noir-repo/examples noir-repo
COPY ../barretenberg/cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb

ENV BACKEND=/usr/src/barretenberg/cpp/build/bin/bb

WORKDIR noir-repo/examples/codegen-verifier
RUN ./test.sh

format:
FROM +nargo
ENV PATH=$PATH:/usr/src/noir-repo/target/release
Expand Down
7 changes: 7 additions & 0 deletions noir/noir-repo/examples/codegen-verifier/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "hello_world"
type = "bin"
authors = [""]
compiler_version = ">=0.29.0"

[dependencies]
10 changes: 10 additions & 0 deletions noir/noir-repo/examples/codegen-verifier/codegen_verifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

BACKEND=${BACKEND:-bb}

nargo compile

# TODO: backend should automatically generate vk if necessary.
$BACKEND write_vk -b ./target/hello_world.json
$BACKEND contract -v ./target/vk
3 changes: 3 additions & 0 deletions noir/noir-repo/examples/codegen-verifier/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x: Field, y: pub Field) {
assert(x != y);
}
13 changes: 13 additions & 0 deletions noir/noir-repo/examples/codegen-verifier/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -eu

# This file is used for Noir CI and is not required.

BACKEND=${BACKEND:-bb}

./codegen_verifier.sh

if ! [ -f ./target/contract.sol ]; then
printf '%s\n' "Contract not written to file" >&2
exit 1
fi

0 comments on commit a22d895

Please sign in to comment.