Skip to content
Open
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
5 changes: 2 additions & 3 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,8 @@ class ECCVMFlavor {
#endif
{
// compute rows for the three different sections of the ECCVM execution trace
// Note: the first operation (index 0) is always a hiding op with random Px, Py values
const auto transcript_rows =
ECCVMTranscriptBuilder::compute_rows(builder.op_queue->get_eccvm_ops(), builder.get_number_of_muls());
const auto transcript_rows = ECCVMTranscriptBuilder::compute_rows(
builder.op_queue->get_eccvm_ops(), builder.get_number_of_muls(), builder.op_queue->get_is_zk());
const std::vector<MSM> msms = builder.get_msms();
const auto point_table_rows =
ECCVMPointTablePrecomputationBuilder::compute_rows(CircuitBuilder::get_flattened_scalar_muls(msms));
Expand Down
12 changes: 8 additions & 4 deletions barretenberg/cpp/src/barretenberg/eccvm/transcript_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class ECCVMTranscriptBuilder {
* @return A vector of TranscriptRows
*/
static std::vector<TranscriptRow> compute_rows(const std::vector<ECCVMOperation>& vm_operations,
const uint32_t total_number_of_muls)
const uint32_t total_number_of_muls,
bool is_zk = true)
{
const size_t num_vm_entries = vm_operations.size();
// The transcript contains an extra zero row at the beginning and the accumulated state at the end
Expand Down Expand Up @@ -173,7 +174,9 @@ class ECCVMTranscriptBuilder {
// Handle hiding op (index 0) separately before the main loop.
// The hiding op has random (non-curve) Px, Py values for ZK purposes - we skip EC computation
// and just record the raw field elements. Uses opcode 3 (q_eq=1, q_reset=1).
{
// When is_zk=false, there is no hiding op and index 0 is a regular op processed by the main loop.
size_t main_loop_start = 0;
if (is_zk) {
const ECCVMOperation& hiding_entry = vm_operations[0];
TranscriptRow& hiding_row = transcript_state[1];

Expand All @@ -189,12 +192,13 @@ class ECCVMTranscriptBuilder {
msm_accumulator_trace[0] = Element::infinity();
intermediate_accumulator_trace[0] = Element::infinity();
msm_count_at_transition_inverse_trace[0] = 0;
main_loop_start = 1;
}

// during the first iteration over the ECCOpQueue, the operations are being performed using Jacobian (a.k.a.
// projective) coordinates and the base point coordinates are recorded in the transcript. at the same time, the
// transcript logic is being populated (starting from index 1, since index 0 is the hiding op handled above)
for (size_t i = 1; i < num_vm_entries; i++) {
// transcript logic is being populated
for (size_t i = main_loop_start; i < num_vm_entries; i++) {
TranscriptRow& row = transcript_state[i + 1];
const ECCVMOperation& entry = vm_operations[i];

Expand Down
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/goblin/goblin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "barretenberg/common/bb_bench.hpp"
#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
#include "barretenberg/eccvm/eccvm_flavor.hpp"
#include "barretenberg/eccvm/eccvm_trace_checker.hpp"
#include "barretenberg/eccvm/eccvm_verifier.hpp"
#include "barretenberg/goblin/goblin_verifier.hpp"
#include "barretenberg/goblin/merge_verifier.hpp"
Expand Down Expand Up @@ -39,7 +38,6 @@ void Goblin::prove_eccvm()
// Scope the builder so it (and any circuit data) is freed before proving
ECCVMProver eccvm_prover = [&]() {
ECCVMBuilder eccvm_builder(op_queue);
info("ECCVM STATUS: ", ECCVMTraceChecker::check(eccvm_builder));
return ECCVMProver(eccvm_builder, transcript);
}();
auto [eccvm_proof, opening_claim] = eccvm_prover.construct_proof();
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 @@ -30,6 +30,8 @@ class Goblin {
bool avm_mode = false;

public:
void set_op_queue_zk(bool is_zk) { op_queue->set_is_zk(is_zk); }

using MegaBuilder = MegaCircuitBuilder;
using Fr = bb::fr;
using Transcript = NativeTranscript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class GoblinRecursiveVerifierTests : public testing::Test {
*/
static ProverOutput create_goblin_prover_output(Builder* outer_builder = nullptr, const size_t num_circuits = 5)
{

Goblin goblin;
goblin.set_op_queue_zk(false);
GoblinMockCircuits::construct_and_merge_mock_circuits(goblin, num_circuits);

// Merge the ecc ops from the newly constructed circuit
Expand Down Expand Up @@ -101,6 +101,7 @@ class GoblinRecursiveVerifierTests : public testing::Test {
*/
TEST_F(GoblinRecursiveVerifierTests, NativeVerification)
{
BB_DISABLE_ASSERTS();
auto [proof, merge_commitments, _] = create_goblin_prover_output();

auto transcript = std::make_shared<NativeTranscript>();
Expand All @@ -125,6 +126,8 @@ TEST_F(GoblinRecursiveVerifierTests, NativeVerification)
*/
TEST_F(GoblinRecursiveVerifierTests, Basic)
{
BB_DISABLE_ASSERTS();

Builder builder;

auto [proof, merge_commitments, recursive_merge_commitments] = create_goblin_prover_output(&builder);
Expand Down
14 changes: 8 additions & 6 deletions barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,19 @@ class GoblinMockCircuits {

static void construct_and_merge_mock_circuits(Goblin& goblin, const size_t num_circuits = 3)
{
using Fq = curve::Grumpkin::ScalarField;
for (size_t idx = 0; idx < num_circuits - 1; ++idx) {
MegaCircuitBuilder builder{ goblin.op_queue };
if (idx == num_circuits - 2) {
// Last circuit appended needs to begin with a no-op for translator to be shiftable
// Last-prepended circuit: its subtable ends up at the top of the table.
// Add leading no-op (for translator shiftable polynomials) + 3 no-ops
// (padding positions [1..3] that the Translator skips in accumulation).
builder.queue_ecc_no_op();
builder.queue_ecc_no_op();
builder.queue_ecc_no_op();
builder.queue_ecc_no_op();
// Add random ops at START for Translator ZK (lands at beginning of op queue table)
randomise_op_queue(builder, TranslatorCircuitBuilder::NUM_RANDOM_OPS_START);
// Add hiding op for ECCVM ZK (prepended to ECCVM ops at row 1)
builder.queue_ecc_hiding_op(Fq::random_element(), Fq::random_element());
}
// Every circuit starts with an eq_and_reset
builder.queue_ecc_eq();
construct_simple_circuit(builder);
goblin.prove_merge();
// Pop the merge proof from the queue, Goblin will be verified at the end
Expand Down
5 changes: 1 addition & 4 deletions barretenberg/cpp/src/barretenberg/op_queue/ecc_op_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ECCOpQueue {

public:
void set_is_zk(bool _is_zk) { is_zk = _is_zk; }
bool get_is_zk() const { return is_zk; }

static const size_t OP_QUEUE_SIZE = 1 << CONST_OP_QUEUE_LOG_SIZE;
/**
Expand Down Expand Up @@ -316,10 +317,6 @@ class ECCOpQueue {
{
auto expected = accumulator;
accumulator.self_set_infinity();
if (expected.is_point_at_infinity()) {
expected.x = Fq(0);
expected.y = Fq(0);
}
EccOpCode op_code{ .eq = true, .reset = true };
// Store eccvm operation
append_eccvm_op(ECCVMOperation{ .op_code = op_code, .base_point = expected });
Expand Down