Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Client IVC API #10217

Merged
merged 31 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
58fad33
WIP exposing CIVC
codygunton Nov 25, 2024
1960bdf
Fix common typo
codygunton Nov 25, 2024
15b0ea4
Attaching attempt doesn't work
codygunton Nov 26, 2024
96c9690
const
codygunton Nov 26, 2024
c263ba0
This works; next make robut
codygunton Nov 26, 2024
6388a0b
Split out folding stack building
codygunton Nov 26, 2024
ec10320
Pare down writes
codygunton Nov 26, 2024
410a829
Handle case of one circuit
codygunton Nov 26, 2024
cac38b5
revert typo
codygunton Nov 26, 2024
2fbd248
Fix prove_then_verify
codygunton Nov 26, 2024
28a9906
Merge remote-tracking branch 'origin/master' into cg/api-civc
codygunton Nov 27, 2024
07cc89e
Fix after merge, resolving vk interface TODO
codygunton Nov 27, 2024
202bd25
Merge remote-tracking branch 'origin/master' into cg/api-civc
codygunton Nov 27, 2024
dea89e0
Uniformize interface with flags var
codygunton Nov 27, 2024
ed993ca
remove bad debug launch
codygunton Nov 27, 2024
52760b2
Client IVC unified
codygunton Nov 29, 2024
9595f28
Merge branch 'master' into cg/api-civc
codygunton Nov 29, 2024
361da96
Don't default --scheme
codygunton Nov 29, 2024
6c721a2
bootstrap formatted
codygunton Nov 29, 2024
4903b8d
Remove use of fold_and_verify; try to fix e2e
codygunton Nov 29, 2024
6954daf
use _ not - in command line params
codygunton Nov 29, 2024
902c4ec
Revert for bb.js
codygunton Nov 29, 2024
a67d8d6
delete stray log
codygunton Nov 29, 2024
ba6cd30
Update verify method ff call
codygunton Nov 29, 2024
7c00eb1
Clean up
codygunton Nov 30, 2024
dab17b3
single_circuit is a compiletime_stack; dep mega flows
codygunton Dec 2, 2024
57d602a
Comments
codygunton Dec 2, 2024
d7614e4
mega ~> civc in gh workflow
codygunton Dec 2, 2024
26e3876
More mega removal
codygunton Dec 2, 2024
a6ce141
Skip failing compiletime folding tests
codygunton Dec 2, 2024
7a1e22c
Skip ram_blowup_regression (redundant, needs more SRS)
codygunton Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ jobs:
timeout-minutes: 40
run: earthly-ci --no-output ./+barretenberg-acir-tests-bb-ultra-honk

bb-acir-tests-bb-mega-honk:
bb-acir-tests-bb-client-ivc:
needs: [noir-build-acir-tests, build, configure]
runs-on: ${{ needs.configure.outputs.username }}-x86
if: needs.configure.outputs.barretenberg == 'true' || needs.configure.outputs.noir == 'true'
Expand All @@ -453,11 +453,11 @@ jobs:
with: { ref: "${{ env.GIT_COMMIT }}" }
- uses: ./.github/ci-setup-action
with:
concurrency_key: barretenberg-acir-tests-bb-mega-honk-x86
- name: "BB Native Acir Tests (Megahonk)"
concurrency_key: barretenberg-acir-tests-bb-client-ivc-x86
- name: "BB Native Acir Tests (ClientIVC)"
working-directory: ./barretenberg/
timeout-minutes: 40
run: earthly-ci --no-output ./+barretenberg-acir-tests-bb-mega-honk
run: earthly-ci --no-output ./+barretenberg-acir-tests-bb-client-ivc

bb-acir-tests-sol:
needs: [noir-build-acir-tests, build, configure]
Expand Down Expand Up @@ -969,7 +969,7 @@ jobs:
- bb-acir-tests-bb
- bb-acir-tests-bb-ultra-plonk
- bb-acir-tests-bb-ultra-honk
- bb-acir-tests-bb-mega-honk
- bb-acir-tests-bb-client-ivc
- bb-acir-tests-sol
- bb-acir-tests-sol-honk
- bb-acir-tests-bb-js
Expand Down
16 changes: 7 additions & 9 deletions barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ barretenberg-acir-tests-bb:
ENV VERBOSE=1

# Fold and verify an ACIR program stack using ClientIvc
RUN FLOW=fold_and_verify_program ./run_acir_tests.sh fold_basic
RUN INPUT_TYPE=compiletime_stack FLOW=prove_and_verify_client_ivc ./run_acir_tests.sh fold_basic
# Fold and verify an ACIR program stack using ClientIvc, then natively verify the ClientIVC proof.
RUN FLOW=prove_then_verify_client_ivc ./run_acir_tests.sh fold_basic
RUN INPUT_TYPE=compiletime_stack FLOW=prove_then_verify_client_ivc ./run_acir_tests.sh fold_basic
# Fold and verify an ACIR program stack using ClientIvc, recursively verify as part of the Tube circuit and produce and verify a Honk proof
RUN FLOW=prove_then_verify_tube ./run_acir_tests.sh fold_basic
# Run 1_mul through native bb build, all_cmds flow, to test all cli args.
Expand Down Expand Up @@ -79,7 +79,7 @@ barretenberg-acir-tests-bb-ultra-honk:
# Construct and verify a UltraHonk proof for a single program that recursively verifies a Honk proof
RUN FLOW=prove_and_verify_ultra_honk ./run_acir_tests.sh verify_honk_proof

barretenberg-acir-tests-bb-mega-honk:
barretenberg-acir-tests-bb-client-ivc:
FROM ../build-images/+from-registry

COPY ./cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb
Expand All @@ -92,12 +92,10 @@ barretenberg-acir-tests-bb-mega-honk:
ENV TEST_SRC /usr/src/acir_artifacts
ENV VERBOSE=1

# Construct and separately verify a MegaHonk proof for all acir programs
RUN FLOW=prove_then_verify_mega_honk ./run_acir_tests.sh
# Construct and verify a MegaHonk proof for a single arbitrary program
RUN FLOW=prove_and_verify_mega_honk ./run_acir_tests.sh 6_array
# Construct and verify a MegaHonk proof for all ACIR programs using the new witness stack workflow
RUN FLOW=prove_and_verify_mega_honk_program ./run_acir_tests.sh
# Construct and verify a ClientIVC proof for a single arbitrary program
RUN FLOW=prove_and_verify_client_ivc ./run_acir_tests.sh 6_array
# Construct and separately verify a ClientIVC proof for all acir programs
RUN FLOW=prove_then_verify_client_ivc CLIENT_IVC_SKIPS=true ./run_acir_tests.sh

barretenberg-acir-tests-sol:
FROM ../build-images/+from-registry
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/acir_tests/flows/fold_and_verify_program.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
set -eu

# this flow is deprecated. currently it is bb.js only. for bb is is replaced by:
# prove_and_verify --scheme client_ivc --input-type compiletime_stack
VFLAG=${VERBOSE:+-v}

$BIN fold_and_verify_program $VFLAG -c $CRS_PATH -b ./target/program.json
9 changes: 9 additions & 0 deletions barretenberg/acir_tests/flows/prove_and_verify_client_ivc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu

VFLAG=${VERBOSE:+-v}
INFLAG=${INPUT_TYPE=compiletime_stack}

FLAGS="$CRS_PATH -b ./target/program.json $VFLAG --scheme client_ivc -c --input_type $INFLAG"

$BIN prove_and_verify $FLAGS
5 changes: 5 additions & 0 deletions barretenberg/acir_tests/flows/prove_and_verify_mega_honk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ set -eu

VFLAG=${VERBOSE:+-v}

# this flow is deprecated. currently it is bb.js only. for bb is is replaced by:
# prove_and_verify --scheme client_ivc --input-type compiletime_stack
# NB: In general, it is not meaningful to produce a MegaHonk proof an its own since
# the MegaHonk proof does not attest to the correctness of every possible kind
# of gate that could appear in a Mega execution trace.
$BIN prove_and_verify_mega_honk $VFLAG -c $CRS_PATH -b ./target/program.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ set -eu

VFLAG=${VERBOSE:+-v}

# this flow is deprecated. currently it is bb.js only. for bb is is replaced by:
# prove_and_verify --scheme client_ivc --input-type compiletime_stack
# NB: In general, it is not meaningful to produce a MegaHonk proof an its own since
# the MegaHonk proof does not attest to the correctness of every possible kind
# of gate that could appear in a Mega execution trace.
$BIN prove_and_verify_mega_honk_program $VFLAG -c $CRS_PATH -b ./target/program.json
8 changes: 5 additions & 3 deletions barretenberg/acir_tests/flows/prove_then_verify_client_ivc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ set -eu

VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
FLAGS="-c $CRS_PATH $VFLAG"
INFLAG=${INPUT_TYPE=compiletime_stack}

$BIN client_ivc_prove_output_all $FLAGS $BFLAG
$BIN verify_client_ivc $FLAGS
FLAGS="--scheme client_ivc -c $CRS_PATH $VFLAG"

$BIN prove $FLAGS $BFLAG --input_type $INFLAG
$BIN verify $FLAGS
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/flows/prove_then_verify_tube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mkdir -p ./proofs

VFLAG=${VERBOSE:+-v}

$BIN client_ivc_prove_output_all $VFLAG -c $CRS_PATH -b ./target/program.json
$BIN prove --scheme client_ivc --input_type compiletime_stack $VFLAG -c $CRS_PATH -b ./target/program.json
$BIN prove_tube -k vk -p proof -c $CRS_PATH $VFLAG
$BIN verify_tube -k vk -p proof -c $CRS_PATH $VFLAG

2 changes: 1 addition & 1 deletion barretenberg/acir_tests/flows/prove_tube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
FLAGS="-c $CRS_PATH $VFLAG"

$BIN client_ivc_prove_output_all $VFLAG -c $CRS_PATH -b ./target/program.json
$BIN prove --scheme client_ivc --input_type compiletime_stack $VFLAG -c $CRS_PATH -b ./target/program.json
$BIN prove_tube -k vk -p proof $FLAGS
16 changes: 16 additions & 0 deletions barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trap handle_sigchild SIGCHLD
BIN=${BIN:-../cpp/build/bin/bb}
FLOW=${FLOW:-prove_and_verify}
HONK=${HONK:-false}
CLIENT_IVC_SKIPS=${CLIENT_IVC_SKIPS:-false}
CRS_PATH=~/.bb-crs
BRANCH=master
VERBOSE=${VERBOSE:-}
Expand Down Expand Up @@ -57,6 +58,21 @@ if [ "$HONK" = true ]; then
SKIP_ARRAY+=(single_verify_proof double_verify_proof double_verify_nested_proof)
fi

if [ "$CLIENT_IVC_SKIPS" = true ]; then
# At least for now, skip folding tests that fail when run against ClientIVC.
# This is not a regression--folding was not being properly tested.
# TODO(https://github.com/AztecProtocol/barretenberg/issues/1164): Resolve this
# The reason for failure is that compile-time folding, as initially conceived, is
# only supported by ClientIVC through hacks. ClientIVC in Aztec is ultimately to be
# used through runtime folding, since the kernels that are needed are detected and
# constructed at runtime in Aztec's typescript proving interface. ClientIVC appends
# folding verifiers and does databus and Goblin merge work depending on its inputs,
# detecting which circuits are Aztec kernels. These tests may simple fail for trivial
# reasons, e.g. because the number of circuits in the stack is odd.
SKIP_ARRAY+=(fold_basic_nested_call fold_fibonacci fold_numeric_generic_poseidon ram_blowup_regression)
fi


function test() {
cd $1

Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/docs/src/sumcheck-outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ Observe that \f$ G \f$ has several important properties
- The coefficients of \f$ G \f$ are independent and uniformly distributed.
- Evaluations of \f$ G \f$ at \f$ \vec \ell \in \{0,1\}^d\f$ and related Sumcheck Round Univariates are efficiently computable.

The first two properties imply that the evaluations of Sumcheck Round Univariates for \f$G\f$ are independent and uniformly distributed. We call them Libra Round Univarites.
The first two properties imply that the evaluations of Sumcheck Round Univariates for \f$G\f$ are independent and uniformly distributed. We call them Libra Round Univariates.

Consider Round Univariates for \f$ \tilde{F} + \texttt{libra_challenge}\cdot G\f$ which are the sums of the Sumcheck Round Univariates for \f$ \tilde{F} \f$ and Libra Round Univarites multiplied by the challenge.
Consider Round Univariates for \f$ \tilde{F} + \texttt{libra_challenge}\cdot G\f$ which are the sums of the Sumcheck Round Univariates for \f$ \tilde{F} \f$ and Libra Round Univariates multiplied by the challenge.
The fact that the degrees of Libra Round Univariates are big enough (i.e. \f$ \tilde{D}\geq D \f$) and that their evaluations are random imply that the evaluations \f$ \tilde{S}^i(0),\ldots,\tilde{S}^i(\tilde D)\f$ defined in [Compute Round Univariates](#ComputeRoundUnivariates) are now masked by the evaluations of Libra Round Univariates. These evaluations are described explicitly [below](#LibraRoundUnivariates).

### Example {#LibraPolynomialExample}
Expand Down
34 changes: 34 additions & 0 deletions barretenberg/cpp/src/barretenberg/bb/acir_format_getters.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include "barretenberg/bb/config.hpp"
#include "barretenberg/bb/file_io.hpp"
#include "barretenberg/bb/get_bytecode.hpp"
#include "barretenberg/dsl/acir_format/acir_format.hpp"
#include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp"

namespace bb {

acir_format::WitnessVector get_witness(std::string const& witness_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great to have docs for each of this getter but not part of the focus of this PR.

{
auto witness_data = get_bytecode(witness_path);
return acir_format::witness_buf_to_witness_data(witness_data);
}

acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path, bool honk_recursion)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::circuit_buf_to_acir_format(bytecode, honk_recursion);
}

acir_format::WitnessVectorStack get_witness_stack(std::string const& witness_path)
{
auto witness_data = get_bytecode(witness_path);
return acir_format::witness_buf_to_witness_stack(witness_data);
}

std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path, bool honk_recursion)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::program_buf_to_acir_format(bytecode, honk_recursion);
}

} // namespace bb
39 changes: 39 additions & 0 deletions barretenberg/cpp/src/barretenberg/bb/api.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
#include <filesystem>

namespace bb {

class API {
public:
struct Flags {
std::optional<std::string> output_type; // bytes, fields, bytes_and_fields, fields_msgpack
std::optional<std::string> input_type; // compiletime_stack, runtime_stack
};

virtual void prove(const Flags& flags,
const std::filesystem::path& bytecode_path,
const std::filesystem::path& witness_path,
const std::filesystem::path& output_dir) = 0;

virtual bool verify(const Flags& flags,
const std::filesystem::path& proof_path,
const std::filesystem::path& vk_path) = 0;

virtual bool prove_and_verify(const Flags& flags,
const std::filesystem::path& bytecode_path,
const std::filesystem::path& witness_path) = 0;

virtual void gates(const Flags& flags,
const std::filesystem::path& bytecode_path,
const std::filesystem::path& witness_path) = 0;

virtual void contract(const Flags& flags,
const std::filesystem::path& output_path,
const std::filesystem::path& vk_path) = 0;

virtual void to_fields(const Flags& flags,
const std::filesystem::path& proof_path,
const std::filesystem::path& vk_path,
const std::filesystem::path& output_path) = 0;
};
} // namespace bb
Loading
Loading