Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 @@ -99,7 +99,7 @@ void create_dummy_vkey_and_proof(typename Flavor::CircuitBuilder& builder,
}
// The aggregation object
for (size_t i = 0; i < AggregationObject::PUBLIC_INPUTS_SIZE; i++) {
builder.assert_equal(builder.add_variable(fr::random_element()), proof_fields[offset].witness_index);
builder.assert_equal(builder.add_variable(2), proof_fields[offset].witness_index);
Comment thread
lucasxia01 marked this conversation as resolved.
Outdated
offset++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ template <typename RecursiveFlavor> class AcirHonkRecursionConstraint : public :
* @param inner_circuits
* @return Composer
*/
template <typename BuilderType> BuilderType create_outer_circuit(std::vector<InnerBuilder>& inner_circuits)
template <typename BuilderType>
BuilderType create_outer_circuit(std::vector<InnerBuilder>& inner_circuits, bool dummy_witnesses = false)
{
std::vector<RecursionConstraint> honk_recursion_constraints;

Expand Down Expand Up @@ -208,6 +209,9 @@ template <typename RecursiveFlavor> class AcirHonkRecursionConstraint : public :
honk_recursion = 2;
}
ProgramMetadata metadata{ .honk_recursion = honk_recursion };
if (dummy_witnesses) {
witness = {}; // set it all to 0

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.

I think this is all we need to do to in order to trigger the dummy witness generation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's right

}
AcirProgram program{ constraint_system, witness };
BuilderType outer_circuit = create_circuit<BuilderType>(program, metadata);

Expand All @@ -228,6 +232,30 @@ using Flavors = testing::Types<UltraRecursiveFlavor_<UltraCircuitBuilder>,

TYPED_TEST_SUITE(AcirHonkRecursionConstraint, Flavors);

TYPED_TEST(AcirHonkRecursionConstraint, TestHonkRecursionConstraintVKGeneration)
{
std::vector<typename TestFixture::InnerBuilder> layer_1_circuits;
layer_1_circuits.push_back(TestFixture::create_inner_circuit());

auto layer_2_circuit =
TestFixture::template create_outer_circuit<typename TestFixture::OuterBuilder>(layer_1_circuits);

auto layer_2_circuit_with_dummy_witnesses =
TestFixture::template create_outer_circuit<typename TestFixture::OuterBuilder>(layer_1_circuits,
/*dummy_witnesses=*/true);

auto proving_key = std::make_shared<typename TestFixture::OuterDeciderProvingKey>(layer_2_circuit);
auto verification_key = std::make_shared<typename TestFixture::OuterVerificationKey>(proving_key->proving_key);

auto proving_key_dummy =
std::make_shared<typename TestFixture::OuterDeciderProvingKey>(layer_2_circuit_with_dummy_witnesses);
auto verification_key_dummy =
std::make_shared<typename TestFixture::OuterVerificationKey>(proving_key_dummy->proving_key);

// Compare the two vks
EXPECT_EQ(*verification_key_dummy, *verification_key);
}

TYPED_TEST(AcirHonkRecursionConstraint, TestBasicSingleHonkRecursionConstraint)
{
std::vector<typename TestFixture::InnerBuilder> layer_1_circuits;
Expand All @@ -243,7 +271,7 @@ TYPED_TEST(AcirHonkRecursionConstraint, TestBasicSingleHonkRecursionConstraint)
info("prover gates = ", proving_key->proving_key.circuit_size);
auto proof = prover.construct_proof();
auto verification_key = std::make_shared<typename TestFixture::OuterVerificationKey>(proving_key->proving_key);
info(HasIPAAccumulator<TypeParam>);

if constexpr (HasIPAAccumulator<TypeParam>) {
auto ipa_verification_key = std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(1 << CONST_ECCVM_LOG_N);
typename TestFixture::OuterVerifier verifier(verification_key, ipa_verification_key);
Expand Down
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,6 @@ class ECCVMFlavor {
*/
class VerificationKey : public VerificationKey_<uint64_t, PrecomputedEntities<Commitment>, VerifierCommitmentKey> {
public:
bool operator==(const VerificationKey&) const = default;

// Default construct the fixed VK that results from ECCVM_FIXED_SIZE
VerificationKey()
: VerificationKey_(ECCVM_FIXED_SIZE, /*num_public_inputs=*/0)
Expand Down
14 changes: 13 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,19 @@ class VerificationKey_ : public PrecomputedCommitments {
bool contains_pairing_point_accumulator = false;
PairingPointAccumulatorPubInputIndices pairing_point_accumulator_public_input_indices = {};

bool operator==(const VerificationKey_&) const = default;
bool operator==(const VerificationKey_& other) const
Comment thread
lucasxia01 marked this conversation as resolved.
Outdated
{
bool equal = true;
equal &= this->circuit_size == other.circuit_size;
equal &= this->log_circuit_size == other.log_circuit_size;
equal &= this->num_public_inputs == other.num_public_inputs;
equal &= this->pub_inputs_offset == other.pub_inputs_offset;
equal &= this->contains_pairing_point_accumulator == other.contains_pairing_point_accumulator;
for (auto [comm, other_comm] : zip_view(this->get_all(), other.get_all())) {
equal &= comm == other_comm;
}
return equal;
}
VerificationKey_() = default;
VerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_

auto pairing_points = PCS::reduce_verify_batch_opening_claim(opening_claim, transcript);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1352): Investigate if normalize() calls are needed.

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.

my guess is that these are not needed

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ class MegaFlavor {
// Data pertaining to transfer of databus return data via public inputs of the proof being recursively verified
DatabusPropagationData databus_propagation_data;

bool operator==(const VerificationKey&) const = default;
bool operator==(const VerificationKey& other) const
{
// call parent one
Comment thread
lucasxia01 marked this conversation as resolved.
Outdated
return (VerificationKey_::operator==(other) && databus_propagation_data == other.databus_propagation_data);
}
VerificationKey() = default;
VerificationKey(const size_t circuit_size, const size_t num_public_inputs)
: VerificationKey_(circuit_size, num_public_inputs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ class UltraFlavor {
*/
class VerificationKey : public VerificationKey_<uint64_t, PrecomputedEntities<Commitment>, VerifierCommitmentKey> {
public:
bool operator==(const VerificationKey&) const = default;
VerificationKey() = default;
VerificationKey(const size_t circuit_size, const size_t num_public_inputs)
: VerificationKey_(circuit_size, num_public_inputs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ class UltraRollupFlavor : public bb::UltraFlavor {
bool contains_ipa_claim;
IPAClaimPubInputIndices ipa_claim_public_input_indices;

bool operator==(const VerificationKey&) const = default;
bool operator==(const VerificationKey& other) const
Comment thread
lucasxia01 marked this conversation as resolved.
Outdated
{
// call the parent one
return (VerificationKey_::operator==(other) && contains_ipa_claim == other.contains_ipa_claim &&
ipa_claim_public_input_indices == other.ipa_claim_public_input_indices);
}
VerificationKey() = default;
VerificationKey(const size_t circuit_size, const size_t num_public_inputs)
: VerificationKey_(circuit_size, num_public_inputs)
Expand Down