Skip to content

Commit

Permalink
Browser tests of honk; cannot verify honk proof in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Oct 7, 2024
1 parent fe11d9a commit b09a7c7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
39 changes: 20 additions & 19 deletions barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,27 @@ barretenberg-acir-tests-bb.js:
# We have diminishing returns after 32 cores, and unnecessarily use resources
ENV HARDWARE_CONCURRENCY=32

# TODO(https://github.com/noir-lang/noir/issues/5106)
# TODO(https://github.com/AztecProtocol/aztec-packages/issues/6672)c
# Run ecdsa_secp256r1_3x through bb.js on node to check 256k support.
RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify ./run_acir_tests.sh ecdsa_secp256r1_3x
# Run a single arbitrary test not involving recursion through bb.js for UltraHonk
RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_ultra_honk ./run_acir_tests.sh 6_array assert_statement
# Run the prove then verify flow for UltraHonk. This makes sure we have the same circuit for different witness inputs.
RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh 6_array assert_statement
# Run a single arbitrary test not involving recursion through bb.js for MegaHonk
RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_mega_honk ./run_acir_tests.sh 6_array
# Run fold_basic test through bb.js which runs ClientIVC on fold basic
RUN BIN=../ts/dest/node/main.js FLOW=fold_and_verify_program ./run_acir_tests.sh fold_basic
# Run 1_mul through bb.js build, all_cmds flow, to test all cli args.
RUN BIN=../ts/dest/node/main.js FLOW=all_cmds ./run_acir_tests.sh 1_mul
# TODO(https://github.com/AztecProtocol/aztec-packages/issues/6672)
# Run 6_array through bb.js on chrome testing multi-threaded browser support.
# TODO: Currently headless webkit doesn't seem to have shared memory so skipping multi-threaded test.
RUN BROWSER=chrome THREAD_MODEL=mt ./run_acir_tests_browser.sh 6_array
# # TODO(https://github.com/noir-lang/noir/issues/5106)
# # TODO(https://github.com/AztecProtocol/aztec-packages/issues/6672)c
# # Run ecdsa_secp256r1_3x through bb.js on node to check 256k support.
# RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify ./run_acir_tests.sh ecdsa_secp256r1_3x
# # Run a single arbitrary test not involving recursion through bb.js for UltraHonk
# RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_ultra_honk ./run_acir_tests.sh 6_array assert_statement
# # Run the prove then verify flow for UltraHonk. This makes sure we have the same circuit for different witness inputs.
# RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh 6_array assert_statement
# # Run a single arbitrary test not involving recursion through bb.js for MegaHonk
# RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_mega_honk ./run_acir_tests.sh 6_array
# # Run fold_basic test through bb.js which runs ClientIVC on fold basic
# RUN BIN=../ts/dest/node/main.js FLOW=fold_and_verify_program ./run_acir_tests.sh fold_basic
# # Run 1_mul through bb.js build, all_cmds flow, to test all cli args.
# RUN BIN=../ts/dest/node/main.js FLOW=all_cmds ./run_acir_tests.sh 1_mul
# # TODO(https://github.com/AztecProtocol/aztec-packages/issues/6672)
# # Run 6_array through bb.js on chrome testing multi-threaded browser support.
# # TODO: Currently headless webkit doesn't seem to have shared memory so skipping multi-threaded test.
RUN BROWSER=chrome THREAD_MODEL=mt FLOW=prove_and_verify_ultra_honk ./run_acir_tests_browser.sh 6_array
# Run 1_mul through bb.js on chrome/webkit testing single threaded browser support.
RUN BROWSER=chrome THREAD_MODEL=st ./run_acir_tests_browser.sh 1_mul
RUN BROWSER=chrome THREAD_MODEL=st FLOW=prove_and_verify_ultra_honk ./run_acir_tests_browser.sh 1_mul
# Commenting for now as fails intermittently. Unreproducable on mainframe.
RU`N BROWSER=chrome THREAD_MODEL=mt FLOW=prove_and_verify_ultra_honk ./run_acir_tests_browser.sh verify_honk_proof
# See https://github.com/AztecProtocol/aztec-packages/issues/2104
#RUN BROWSER=webkit THREAD_MODEL=st ./run_acir_tests_browser.sh 1_mul
6 changes: 3 additions & 3 deletions barretenberg/acir_tests/browser-test-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ async function runTest(
witness: Uint8Array,
threads?: number
) {
const { UltraPlonkBackend, BarretenbergVerifier } = await import("@aztec/bb.js");
const { UltraHonkBackend, BarretenbergVerifier } = await import("@aztec/bb.js");

debug("starting test...");
const backend = new UltraPlonkBackend(bytecode, { threads });
const backend = new UltraHonkBackend(bytecode, { threads });
const proof = await backend.generateProof(witness);

const verificationKey = await backend.getVerificationKey();
await backend.destroy();

debug(`verifying...`);
const verifier = new BarretenbergVerifier({ threads });
const verified = await verifier.verifyUltraplonkProof(proof, verificationKey);
const verified = await verifier.verifyUltrahonkProof(proof, verificationKey);
debug(`verified: ${verified}`);

await verifier.destroy();
Expand Down
1 change: 1 addition & 0 deletions barretenberg/acir_tests/headless-test/bb.js.browser
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
set -eux
SCRIPT_PATH=$(dirname $(realpath $0))
export TS_NODE_PROJECT="$SCRIPT_PATH/tsconfig.json"
NODE_OPTIONS="--loader $SCRIPT_PATH/node_modules/ts-node/esm/transpile-only.mjs --no-warnings" node $SCRIPT_PATH/src/index.ts $@
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/headless-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ program.option("-v, --verbose", "verbose logging");
program.option("-c, --crs-path <path>", "ignored (here for compatibility)");

program
.command("prove_and_verify")
.command("prove_and_verify_ultra_honk")
.description(
"Generate a proof and verify it. Process exits with success or failure code."
)
Expand Down

0 comments on commit b09a7c7

Please sign in to comment.