-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests for noir<>ivc integration testing (#7931)
Adds a new suite of "mocked" protocol circuits that follow the same IVC scheme as the real ones. This allow us to do integration testing between the noir tools to implement ClientIVC (databus, verify_proof, etc) and barretenberg. Added a test in yarn-project using this mocked protocol circuits to create&verify ClientIVC proofs.
- Loading branch information
1 parent
9e8ba96
commit 7cc47a6
Showing
47 changed files
with
2,023 additions
and
1,195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Prover.toml | ||
Verifier.toml | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[workspace] | ||
members = [ | ||
"crates/mock-types", | ||
"crates/app-creator", | ||
"crates/app-reader", | ||
"crates/mock-private-kernel-init", | ||
"crates/mock-private-kernel-inner", | ||
"crates/mock-private-kernel-reset", | ||
"crates/mock-private-kernel-tail", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Mocked protocol circuits | ||
|
||
These simplified circuits act as a way of testing the IVC integration between noir and barretenberg. They follow the same IVC scheme as the real circuits, but are much simpler and easier to reason about. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
cd "$(dirname "$0")" | ||
|
||
CMD=${1:-} | ||
|
||
if [ -n "$CMD" ]; then | ||
if [ "$CMD" = "clean" ]; then | ||
git clean -fdx | ||
exit 0 | ||
else | ||
echo "Unknown command: $CMD" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo} | ||
$NARGO compile --silence-warnings | ||
|
||
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 | ||
mkdir -p "./target/keys" | ||
|
||
for pathname in "./target"/*.json; do | ||
BB_HASH=$BB_HASH node ../scripts/generate_vk_json.js "$pathname" "./target/keys" & | ||
done | ||
|
||
for job in $(jobs -p); do | ||
wait $job || exit 1 | ||
done |
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/app-creator/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "app_creator" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
10 changes: 10 additions & 0 deletions
10
noir-projects/mock-protocol-circuits/crates/app-creator/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use dep::mock_types::{AppPublicInputs, MAX_COMMITMENTS_PER_CALL}; | ||
|
||
// Mock app for testing that creates the commitments the user commands. | ||
// Note: A zero is a null commitment. | ||
fn main(commitments_to_create: [Field; MAX_COMMITMENTS_PER_CALL]) -> pub AppPublicInputs { | ||
let mut result = AppPublicInputs::default(); | ||
result.commitments = commitments_to_create; | ||
result | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/app-reader/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "app_reader" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
10 changes: 10 additions & 0 deletions
10
noir-projects/mock-protocol-circuits/crates/app-reader/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use dep::mock_types::{AppPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_CALL}; | ||
|
||
// Mock app for testing that reads the commitments (generates read requests) the user commands. | ||
// Note: A zero read is a null read. | ||
fn main(commitments_to_read: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_CALL]) -> pub AppPublicInputs { | ||
let mut result = AppPublicInputs::default(); | ||
result.read_requests = commitments_to_read; | ||
result | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "mock_private_kernel_init" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use dep::mock_types::{TxRequest, PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs}; | ||
|
||
fn main(tx: TxRequest, app_inputs: AppPublicInputs) -> pub PrivateKernelPublicInputs { | ||
let mut private_kernel_inputs = PrivateKernelPublicInputsBuilder::from_tx(tx); | ||
private_kernel_inputs.ingest_app_inputs(app_inputs); | ||
private_kernel_inputs.finish() | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "mock_private_kernel_inner" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
11 changes: 11 additions & 0 deletions
11
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use dep::mock_types::{PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs}; | ||
|
||
fn main( | ||
prev_kernel_public_inputs: PrivateKernelPublicInputs, | ||
app_inputs: AppPublicInputs | ||
) -> pub PrivateKernelPublicInputs { | ||
let mut private_kernel_inputs = PrivateKernelPublicInputsBuilder::from_previous_kernel(prev_kernel_public_inputs); | ||
private_kernel_inputs.ingest_app_inputs(app_inputs); | ||
private_kernel_inputs.finish() | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "mock_private_kernel_reset" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
22 changes: 22 additions & 0 deletions
22
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use dep::mock_types::{ | ||
PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, MAX_COMMITMENT_READ_REQUESTS_PER_TX, | ||
MAX_COMMITMENTS_PER_TX | ||
}; | ||
|
||
// Mock reset kernel that reset read requests. | ||
// It needs hints to locate the commitment that matches the read requests. | ||
fn main( | ||
mut prev_kernel_public_inputs: PrivateKernelPublicInputs, | ||
commitment_read_hints: [u32; MAX_COMMITMENT_READ_REQUESTS_PER_TX] | ||
) -> pub PrivateKernelPublicInputs { | ||
for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX { | ||
if commitment_read_hints[i] != MAX_COMMITMENTS_PER_TX { | ||
assert_eq( | ||
prev_kernel_public_inputs.commitments[commitment_read_hints[i]], prev_kernel_public_inputs.read_requests[i] | ||
); | ||
prev_kernel_public_inputs.read_requests[i] = 0; | ||
} | ||
} | ||
prev_kernel_public_inputs | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "mock_private_kernel_tail" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] | ||
mock_types = { path = "../mock-types" } |
15 changes: 15 additions & 0 deletions
15
noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use dep::mock_types::{ | ||
PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, KernelPublicInputs, | ||
MAX_COMMITMENT_READ_REQUESTS_PER_TX | ||
}; | ||
|
||
// The tail kernel finishes the client IVC chain exposing the final public inputs with no remaining calls or unfulfilled read requests. | ||
fn main(prev_kernel_public_inputs: PrivateKernelPublicInputs) -> pub KernelPublicInputs { | ||
assert_eq(prev_kernel_public_inputs.remaining_calls, 0); | ||
for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX { | ||
assert_eq(prev_kernel_public_inputs.read_requests[i], 0); | ||
} | ||
|
||
KernelPublicInputs { commitments: prev_kernel_public_inputs.commitments } | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
noir-projects/mock-protocol-circuits/crates/mock-types/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "mock_types" | ||
type = "lib" | ||
authors = [""] | ||
compiler_version = ">=0.32.0" | ||
|
||
[dependencies] |
Oops, something went wrong.