Skip to content
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
35475e2
wip
zac-williamson Oct 29, 2024
8cb78b5
cycle_group::batch_mul batches modular inversions during witness gene…
zac-williamson Oct 30, 2024
7b80a03
removed x_coordinate_check from straus_lookup_table
zac-williamson Oct 30, 2024
850db1b
removed debug code
zac-williamson Oct 30, 2024
ca6da54
minor optimization to remove 12 gates per mul in `batch_mul` when the…
zac-williamson Oct 30, 2024
a6f4335
wip
zac-williamson Oct 30, 2024
78c9b26
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Oct 30, 2024
1e1668f
minor efficiency improvements for straus_lookup_table constructor
zac-williamson Oct 30, 2024
96cedff
disabled join split circuit change test
zac-williamson Nov 5, 2024
2dcde30
compiler fix
zac-williamson Nov 6, 2024
6be66d3
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Nov 6, 2024
0a5ee12
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Dec 11, 2024
f841ba0
fixed wasm compiler error
zac-williamson Dec 11, 2024
45c060f
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Dec 11, 2024
4959284
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Dec 12, 2024
267d8ad
added comments and added back in join_split_test
zac-williamson Dec 12, 2024
a9f0629
added missing hint description
zac-williamson Dec 12, 2024
197cf5d
grammar
zac-williamson Dec 12, 2024
6365a91
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Dec 12, 2024
4379bfb
PR comments
zac-williamson Dec 20, 2024
95d3816
Merge branch 'master' into zw/cycle-group-witgen
zac-williamson Dec 20, 2024
3d7bc01
wip
zac-williamson Feb 5, 2025
555c705
working complete (I think) circuit that takes in AVM proof and spits …
zac-williamson Mar 7, 2025
dc50c48
moved recursive verifier into separate file
zac-williamson Mar 19, 2025
dd65108
working tests + new dsl method for avm recursion constraint
zac-williamson Mar 20, 2025
3951df8
formatting
zac-williamson Mar 20, 2025
eecc633
separate out PG opt to unique PR
ledwards2225 Mar 20, 2025
cc675dd
Merge branch 'master' into zw/goblin-avm-tests
ledwards2225 Mar 20, 2025
928c8bc
reinstate original avm recursion test
ledwards2225 Mar 20, 2025
d4386eb
touch of cleanup in avm rec constraint
ledwards2225 Mar 20, 2025
3d0f504
cmake cleanup
ledwards2225 Mar 20, 2025
ccb5630
update gen file and remove tmeplate on aggregate method
ledwards2225 Mar 21, 2025
cbee911
cleanup via lambda
ledwards2225 Mar 24, 2025
8b82854
use new avm rec constraint method in test
ledwards2225 Mar 24, 2025
bb07083
Merge branch 'master' into zw/goblin-avm-tests
ledwards2225 Mar 24, 2025
af268a0
remove concept
ledwards2225 Mar 24, 2025
5eaabf0
explicit buildr naming
ledwards2225 Mar 24, 2025
9492122
Merge branch 'master' into zw/goblin-avm-tests
ledwards2225 Mar 24, 2025
2447934
undo agg method template change for testing
ledwards2225 Mar 24, 2025
0f66a40
comment cleanup
ledwards2225 Mar 24, 2025
dd40b1c
use legacy method in avm constraints for now
ledwards2225 Mar 24, 2025
e050056
clarify naming
ledwards2225 Mar 24, 2025
1e7d991
cleanup and simplify gob avm rec verifier plus add issues
ledwards2225 Mar 25, 2025
f9a4c10
WiP test cleanup
ledwards2225 Mar 25, 2025
042d8eb
lots of test cleanup
ledwards2225 Mar 26, 2025
cb0eb92
use legacy method in acir format and add issue
ledwards2225 Mar 26, 2025
98c4759
simplify aggregate method
ledwards2225 Mar 26, 2025
9c5bb95
more comments and cleanup
ledwards2225 Mar 26, 2025
dc84f4e
remove missed WORKTODO
ledwards2225 Mar 26, 2025
df8517e
more cleaup and adding an issue
ledwards2225 Mar 26, 2025
33ce5f0
more comment updates
ledwards2225 Mar 26, 2025
7155b0f
tinyfix
ledwards2225 Mar 27, 2025
1f0c4b3
Merge branch 'master' into zw/goblin-avm-tests
ledwards2225 Mar 31, 2025
46c7525
comment fixes
ledwards2225 Mar 31, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ PairingPointAccumulatorIndices process_avm_recursion_constraints(
// Add recursion constraints
size_t idx = 0;
for (auto& constraint : constraint_system.avm_recursion_constraints) {
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1303): Utilize method that employs Goblin in the
// AVM recursive verifier.
current_aggregation_object = create_avm_recursion_constraints(
builder, constraint, current_aggregation_object, has_valid_witness_assignments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "barretenberg/stdlib/plonk_recursion/aggregation_state/aggregation_state.hpp"
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
#include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp"
#include "barretenberg/vm/avm/recursion/goblin_avm_recursive_verifier.hpp"
#include "barretenberg/vm/avm/recursion/recursive_flavor.hpp"
#include "barretenberg/vm/avm/recursion/recursive_verifier.hpp"
#include "barretenberg/vm/avm/trace/common.hpp"
Expand Down Expand Up @@ -161,24 +162,17 @@ PairingPointAccumulatorIndices create_avm_recursion_constraints(

ASSERT(input.proof_type == AVM);

// Construct an in-circuit representation of the verification key.
std::vector<field_ct> key_fields;
key_fields.reserve(input.key.size());
for (const auto& idx : input.key) {
auto field = field_ct::from_witness_index(&builder, idx);
key_fields.emplace_back(field);
}

auto fields_from_witnesses = [&](std::vector<uint32_t> const& input) {
std::vector<field_ct> result;
result.reserve(input.size());
for (const auto& idx : input) {
auto field = field_ct::from_witness_index(&builder, idx);
result.emplace_back(field);
result.emplace_back(field_ct::from_witness_index(&builder, idx));
}
return result;
};

// Construct in-circuit representation of the verification key, proof and public inputs
const auto key_fields = fields_from_witnesses(input.key);
const auto proof_fields = fields_from_witnesses(input.proof);
const auto public_inputs_flattened = fields_from_witnesses(input.public_inputs);

Expand Down Expand Up @@ -209,5 +203,59 @@ PairingPointAccumulatorIndices create_avm_recursion_constraints(
return output_agg_object.get_witness_indices();
}

// NEW VERSION THAT USES GOBLIN PLONK IN VERIFICATION ALGO
HonkRecursionConstraintOutput create_avm_recursion_constraints_goblin(
Builder& builder,
const RecursionConstraint& input,
PairingPointAccumulatorIndices input_aggregation_object_indices,
bool has_valid_witness_assignments)
{
using RecursiveVerifier = bb::avm::AvmGoblinRecursiveVerifier;

ASSERT(input.proof_type == AVM);

auto fields_from_witnesses = [&](std::vector<uint32_t> const& input) {
std::vector<field_ct> result;
result.reserve(input.size());
for (const auto& idx : input) {
result.emplace_back(field_ct::from_witness_index(&builder, idx));
}
return result;
};

// Construct in-circuit representation of the verification key, proof and public inputs
const auto key_fields = fields_from_witnesses(input.key);
const auto proof_fields = fields_from_witnesses(input.proof);
const auto public_inputs_flattened = fields_from_witnesses(input.public_inputs);

auto it = public_inputs_flattened.begin();
VmPublicInputs vm_public_inputs =
avm_trace::convert_public_inputs(std::vector(it, it + PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH));
it += PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH;
std::vector<field_ct> calldata(it, it + AVM_PUBLIC_COLUMN_MAX_SIZE);
it += AVM_PUBLIC_COLUMN_MAX_SIZE;
std::vector<field_ct> return_data(it, it + AVM_PUBLIC_COLUMN_MAX_SIZE);

auto public_inputs_vectors = avm_trace::copy_public_inputs_columns(vm_public_inputs, calldata, return_data);

// Populate the key fields and proof fields with dummy values to prevent issues (e.g. points must be on curve).
if (!has_valid_witness_assignments) {
create_dummy_vkey_and_proof(builder, input.proof.size(), input.public_inputs.size(), key_fields, proof_fields);
}

// Recursively verify the proof
RecursiveVerifier verifier(&builder, key_fields);
aggregation_state_ct input_agg_obj = bb::stdlib::recursion::convert_witness_indices_to_agg_obj<Builder, bn254>(
builder, input_aggregation_object_indices);
auto output_agg_object = verifier.verify_proof(proof_fields, public_inputs_vectors, input_agg_obj);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/996): investigate whether assert_equal on public
// inputs is important, like what the plonk recursion constraint does.

HonkRecursionConstraintOutput result{ .agg_obj_indices = output_agg_object.aggregation_object.get_witness_indices(),
.ipa_claim = output_agg_object.ipa_claim,
.ipa_proof = output_agg_object.ipa_proof };
return result;
}

} // namespace acir_format
#endif // DISABLE_AZTEC_VM
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef DISABLE_AZTEC_VM
#pragma once
#include "barretenberg/dsl/acir_format/honk_recursion_constraint.hpp"
#include "barretenberg/dsl/acir_format/recursion_constraint.hpp"
#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp"

namespace acir_format {
using Builder = bb::UltraCircuitBuilder;

Expand All @@ -13,5 +13,11 @@ PairingPointAccumulatorIndices create_avm_recursion_constraints(Builder& builder
PairingPointAccumulatorIndices input_aggregation_object,
bool has_valid_witness_assignments);

HonkRecursionConstraintOutput create_avm_recursion_constraints_goblin(
Builder& builder,
const RecursionConstraint& input,
PairingPointAccumulatorIndices input_aggregation_object,
bool has_valid_witness_assignments);

} // namespace acir_format
#endif // DISABLE_AZTEC_VM
#endif // DISABLE_AZTEC_VM
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class AcirAvmRecursionConstraint : public ::testing::Test {
using OuterVerificationKey = UltraFlavor::VerificationKey;
using OuterBuilder = UltraCircuitBuilder;

static void SetUpTestSuite() { bb::srs::init_crs_factory(bb::srs::get_ignition_crs_path()); }
static void SetUpTestSuite()
{
bb::srs::init_crs_factory(bb::srs::get_ignition_crs_path());
bb::srs::init_grumpkin_crs_factory(bb::srs::get_grumpkin_crs_path());
}

// mutate the input kernel_public_inputs_vec to add end gas values
static InnerBuilder create_inner_circuit([[maybe_unused]] std::vector<FF>& kernel_public_inputs_vec)
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ concept IsRecursiveFlavor = IsAnyOf<T, UltraRecursiveFlavor_<UltraCircuitBuilder
TranslatorRecursiveFlavor_<MegaCircuitBuilder>,
TranslatorRecursiveFlavor_<CircuitSimulatorBN254>,
ECCVMRecursiveFlavor_<UltraCircuitBuilder>,
AvmRecursiveFlavor_<UltraCircuitBuilder>>;
AvmRecursiveFlavor_<UltraCircuitBuilder>,
AvmRecursiveFlavor_<MegaCircuitBuilder>>;

// These concepts are relevant for Sumcheck, where the logic is different for BN254 and Grumpkin Flavors
template <typename T> concept IsGrumpkinFlavor = IsAnyOf<T, ECCVMFlavor, ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace bb::stdlib::recursion::honk {

/**
* @brief Runs the Goblin recursive verifier consisting of ECCVM, Translator and Merge verifiers.
* // TODO(https://github.com/AztecProtocol/barretenberg/issues/1309): Implement correct pairing point aggregation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No meaningful changes here just highlighting yet another place where pairing point aggregation is missing.

* Method needs to accept an input agg object, aggregate the pairing points from both translator and merge, then return
* the updated agg object.
*/
GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof& proof)
{
Expand All @@ -15,8 +18,7 @@ GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof&
TranslatorVerifier translator_verifier{ builder,
verification_keys.translator_verification_key,
eccvm_verifier.transcript };

translator_verifier.verify_proof(
[[maybe_unused]] auto translator_pairing_points = translator_verifier.verify_proof(
proof.translator_proof, eccvm_verifier.evaluation_challenge_x, eccvm_verifier.batching_challenge_v);

// Verify the consistency between the ECCVM and Translator transcript polynomial evaluations
Expand All @@ -35,7 +37,7 @@ GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof&

MergeVerifier merge_verifier{ builder };
StdlibProof<Builder> stdlib_merge_proof = bb::convert_native_proof_to_stdlib(builder, proof.merge_proof);
merge_verifier.verify_proof(stdlib_merge_proof);
[[maybe_unused]] auto merge_pairing_points = merge_verifier.verify_proof(stdlib_merge_proof);
return { opening_claim, ipa_transcript };
}
} // namespace bb::stdlib::recursion::honk
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
// TODO(https://github.com/AztecProtocol/barretenberg/issues/995): generate this challenge properly.
typename Curve::ScalarField recursion_separator =
Curve::ScalarField::from_witness_index(builder, builder->add_variable(42));
agg_obj.template aggregate<Builder>(nested_agg_obj, recursion_separator);
agg_obj.aggregate(nested_agg_obj, recursion_separator);

// Execute Sumcheck Verifier and extract multivariate opening point u = (u_0, ..., u_{d-1}) and purported
// multivariate evaluations at u
Expand Down Expand Up @@ -144,7 +144,7 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
pairing_points[0] = pairing_points[0].normalize();
pairing_points[1] = pairing_points[1].normalize();
// TODO(https://github.com/AztecProtocol/barretenberg/issues/995): generate recursion separator challenge properly.
agg_obj.template aggregate<Builder>(pairing_points, recursion_separator);
agg_obj.aggregate(pairing_points, recursion_separator);
output.agg_obj = std::move(agg_obj);

// Extract the IPA claim from the public inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ template <typename Curve> struct aggregation_state {
{
return P0 == other.P0 && P1 == other.P1;
};
template <typename BuilderType = void>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just making a general improvement here. The template param was not needed.

void aggregate(aggregation_state const& other, typename Curve::ScalarField recursion_separator)
{
if constexpr (std::is_same_v<BuilderType, MegaCircuitBuilder>) {
using Builder = typename Curve::Builder;

if constexpr (std::is_same_v<Builder, MegaCircuitBuilder>) {
P0 += other.P0 * recursion_separator;
P1 += other.P1 * recursion_separator;
} else {
Expand All @@ -36,10 +38,11 @@ template <typename Curve> struct aggregation_state {
}
}

template <typename BuilderType = void>
void aggregate(std::array<typename Curve::Group, 2> const& other, typename Curve::ScalarField recursion_separator)
{
if constexpr (std::is_same_v<BuilderType, MegaCircuitBuilder>) {
using Builder = typename Curve::Builder;

if constexpr (std::is_same_v<Builder, MegaCircuitBuilder>) {
P0 += other[0] * recursion_separator;
P1 += other[1] * recursion_separator;
} else {
Expand Down Expand Up @@ -74,6 +77,7 @@ template <typename Curve> struct aggregation_state {
};
return witness_indices;
}

void assign_object_to_proof_outputs()
{
P0 = P0.reduce();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ template <class Builder_, class Fq, class Fr, class NativeGroup> class goblin_el
bool_ct _is_infinity;
};

using BiggroupGoblin = goblin_element<bb::MegaCircuitBuilder,
bb::stdlib::goblin_field<MegaCircuitBuilder>,
stdlib::field_t<MegaCircuitBuilder>,
bb::g1>;

template <typename C, typename Fq, typename Fr, typename G>
inline std::ostream& operator<<(std::ostream& os, goblin_element<C, Fq, Fr, G> const& v)
{
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if(NOT DISABLE_AZTEC_VM)
barretenberg_module(vm sumcheck stdlib_honk_verifier)
endif()
barretenberg_module(vm sumcheck stdlib_honk_verifier stdlib_goblin_verifier)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,6 @@ AvmRecursiveVerifier_<Flavor>::AggregationObject AvmRecursiveVerifier_<Flavor>::
}

template class AvmRecursiveVerifier_<AvmRecursiveFlavor_<UltraCircuitBuilder>>;
template class AvmRecursiveVerifier_<AvmRecursiveFlavor_<MegaCircuitBuilder>>;

} // namespace bb::avm
} // namespace bb::avm
Loading