Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ void ClientIVC::accumulate(ClientCircuit& circuit,
// Construct the proving key for circuit
std::shared_ptr<DeciderProvingKey> proving_key = std::make_shared<DeciderProvingKey>(circuit, trace_settings);

// The commitment key is initialised with the number of points determined by the trace_settings' dyadic size. If a
// circuit overflows past the dyadic size the commitment key will not have enough points so we need to increase it
if (proving_key->proving_key.circuit_size > trace_settings.dyadic_size()) {
// If the current circuit overflows past the current size of the commitment key, reinitialize accordingly.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1319)
if (proving_key->proving_key.circuit_size > bn254_commitment_key->dyadic_size) {
bn254_commitment_key = std::make_shared<CommitmentKey<curve::BN254>>(proving_key->proving_key.circuit_size);
goblin.commitment_key = bn254_commitment_key;
}
Expand Down
13 changes: 9 additions & 4 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,16 @@ class ClientIVC {
ClientIVC(TraceSettings trace_settings = {})
: trace_usage_tracker(trace_settings)
, trace_settings(trace_settings)
, bn254_commitment_key(trace_settings.structure.has_value()
? std::make_shared<CommitmentKey<curve::BN254>>(trace_settings.dyadic_size())
: nullptr)
, goblin(bn254_commitment_key)
{}
{
// Allocate BN254 commitment key based on the max dyadic Mega structured trace size and translator circuit size.
// https://github.com/AztecProtocol/barretenberg/issues/1319): Account for Translator only when it's necessary
size_t commitment_key_size =
std::max(trace_settings.dyadic_size(),
TranslatorFlavor::TRANSLATOR_VM_FIXED_SIZE * TranslatorFlavor::INTERLEAVING_GROUP_SIZE);
info("BN254 commitment key size: ", commitment_key_size);
bn254_commitment_key = std::make_shared<CommitmentKey<curve::BN254>>(commitment_key_size);
}

void instantiate_stdlib_verification_queue(
ClientCircuit& circuit, const std::vector<std::shared_ptr<RecursiveVerificationKey>>& input_keys = {});
Expand Down
30 changes: 30 additions & 0 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

using namespace bb;

static constexpr size_t MAX_NUM_KERNELS = 17;

class ClientIVCTests : public ::testing::Test {
protected:
static void SetUpTestSuite()
Expand Down Expand Up @@ -438,6 +440,34 @@ TEST(ClientIVCBenchValidation, Full6MockedVKs)
ASSERT_NO_FATAL_FAILURE(run_test());
}

TEST(ClientIVCKernelCapacity, MaxCapacityPassing)
{
bb::srs::init_crs_factory(bb::srs::get_ignition_crs_path());
bb::srs::init_grumpkin_crs_factory(bb::srs::get_grumpkin_crs_path());

ClientIVC ivc{ { CLIENT_IVC_BENCH_STRUCTURE } };
const size_t total_num_circuits{ 2 * MAX_NUM_KERNELS };
PrivateFunctionExecutionMockCircuitProducer circuit_producer;
auto precomputed_vkeys = circuit_producer.precompute_verification_keys(total_num_circuits, ivc.trace_settings);
perform_ivc_accumulation_rounds(total_num_circuits, ivc, precomputed_vkeys);
auto proof = ivc.prove();
bool verified = verify_ivc(proof, ivc);
EXPECT_TRUE(verified);
}

TEST(ClientIVCKernelCapacity, MaxCapacityFailing)
{
bb::srs::init_crs_factory(bb::srs::get_ignition_crs_path());
bb::srs::init_grumpkin_crs_factory(bb::srs::get_grumpkin_crs_path());

ClientIVC ivc{ { CLIENT_IVC_BENCH_STRUCTURE } };
const size_t total_num_circuits{ 2 * (MAX_NUM_KERNELS + 1) };
PrivateFunctionExecutionMockCircuitProducer circuit_producer;
auto precomputed_vkeys = circuit_producer.precompute_verification_keys(total_num_circuits, ivc.trace_settings);
perform_ivc_accumulation_rounds(total_num_circuits, ivc, precomputed_vkeys);
EXPECT_ANY_THROW(ivc.prove());
}

/**
* @brief Test use of structured trace overflow block mechanism
* @details Accumulate 4 circuits which have progressively more arithmetic gates. The final two overflow the prescribed
Expand Down
5 changes: 3 additions & 2 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ECCVMFlavor {
// Indicates that this flavor runs with ZK Sumcheck.
static constexpr bool HasZK = true;
// Fixed size of the ECCVM circuits used in ClientIVC
// Important: these constants cannot be arbitrarily changes - please consult with a member of the Crypto team if
// they become too small.
static constexpr size_t ECCVM_FIXED_SIZE = 1UL << CONST_ECCVM_LOG_N;

static constexpr size_t NUM_WIRES = 85;
Expand Down Expand Up @@ -527,8 +529,7 @@ class ECCVMFlavor {
size_t dyadic_num_rows = 1UL << (log_num_rows + (1UL << log_num_rows == num_rows ? 0 : 1));

if ((fixed_size) && (ECCVM_FIXED_SIZE < dyadic_num_rows)) {
info("The ECCVM circuit size has exceeded the fixed upper bound");
ASSERT(false);
throw_or_abort("The ECCVM circuit size has exceeded the fixed upper bound");
}

dyadic_num_rows = fixed_size ? ECCVM_FIXED_SIZE : dyadic_num_rows;
Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/goblin/goblin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class GoblinProver {

PROFILE_THIS_NAME("Goblin::prove");

info("Constructing a Goblin proof with num ultra ops = ", op_queue->get_ultra_ops_table_num_rows());

goblin_proof.merge_proof = merge_proof_in.empty() ? std::move(merge_proof) : std::move(merge_proof_in);
{
PROFILE_THIS_NAME("prove_eccvm");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ template <typename FF_> class TranslatorPermutationRelationImpl {
3 // left-shiftable polynomial sub-relation
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
*
*/
template <typename AllEntities> inline static bool skip(const AllEntities& in)
{
// If z_perm == z_perm_shift, this implies that none of the wire values for the present input are involved in
// non-trivial copy constraints.
return (in.z_perm - in.z_perm_shift).is_zero();
}

inline static auto& get_grand_product_polynomial(auto& in) { return in.z_perm; }
inline static auto& get_shifted_grand_product_polynomial(auto& in) { return in.z_perm_shift; }

Expand Down
Loading
Loading