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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd ..
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
pinned_short_hash="e10fd231"
pinned_short_hash="721d24f8"
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-${pinned_short_hash}.tar.gz"

function compress_and_upload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TranslatorRecursiveTests : public ::testing::Test {
transcript->load_proof(stdlib_proof);
[[maybe_unused]] auto _ = transcript->template receive_from_prover<RecursiveFlavor::BF>("init");

auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(prover.key->proving_key);
auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(prover.key->get_precomputed());
RecursiveVerifier verifier{ &outer_circuit, verification_key, transcript };
typename RecursiveVerifier::PairingPoints pairing_points =
verifier.verify_proof(proof, evaluation_challenge_x, batching_challenge_v);
Expand Down Expand Up @@ -176,9 +176,8 @@ class TranslatorRecursiveTests : public ::testing::Test {
// Generate a proof over the inner circuit
auto inner_proving_key = std::make_shared<TranslatorProvingKey>(inner_circuit);
InnerProver inner_prover(inner_proving_key, prover_transcript);
info("test circuit size: ", inner_proving_key->proving_key->circuit_size);
auto verification_key =
std::make_shared<typename InnerFlavor::VerificationKey>(inner_prover.key->proving_key);
std::make_shared<typename InnerFlavor::VerificationKey>(inner_prover.key->get_precomputed());
auto inner_proof = inner_prover.construct_proof();

// Create a recursive verification circuit for the proof of the inner circuit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ TEST_F(TranslatorRelationCorrectnessTests, ZeroKnowledgePermutation)
const size_t full_masking_offset = NUM_DISABLED_ROWS_IN_SUMCHECK * Flavor::INTERLEAVING_GROUP_SIZE;

TranslatorProvingKey key{};
key.proving_key = std::make_shared<typename Flavor::ProvingKey>();
ProverPolynomials& prover_polynomials = key.proving_key->polynomials;
ProverPolynomials& prover_polynomials = key.polynomials;
const size_t dyadic_circuit_size_without_masking = full_circuit_size - full_masking_offset;

// Fill required relation parameters
Expand Down Expand Up @@ -632,9 +631,8 @@ TEST_F(TranslatorRelationCorrectnessTests, ZeroKnowledgeDeltaRange)
using ProverPolynomials = typename Flavor::ProverPolynomials;
auto& engine = numeric::get_debug_randomness();

TranslatorProvingKey key;
key.proving_key = std::make_shared<typename Flavor::ProvingKey>();
ProverPolynomials& prover_polynomials = key.proving_key->polynomials;
TranslatorProvingKey key{};
ProverPolynomials& prover_polynomials = key.polynomials;

const size_t full_masking_offset = NUM_DISABLED_ROWS_IN_SUMCHECK * Flavor::INTERLEAVING_GROUP_SIZE;
const size_t dyadic_circuit_size_without_masking = TranslatorProvingKey::dyadic_circuit_size_without_masking;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TranslatorTests : public ::testing::Test {
auto proof = prover.construct_proof();

// Create verifier
auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->proving_key);
auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->get_precomputed());
TranslatorVerifier verifier(verification_key, verifier_transcript);

// Verify proof and return result
Expand Down Expand Up @@ -193,7 +193,7 @@ TEST_F(TranslatorTests, FixedVK)
generate_test_circuit(batching_challenge_v, evaluation_challenge_x, circuit_size_parameter);
auto proving_key = std::make_shared<TranslatorProvingKey>(circuit_builder);
TranslatorProver prover{ proving_key, prover_transcript };
TranslatorFlavor::VerificationKey computed_vk(proving_key->proving_key);
TranslatorFlavor::VerificationKey computed_vk(proving_key->get_precomputed());
auto labels = TranslatorFlavor::VerificationKey::get_labels();
size_t index = 0;
for (auto [vk_commitment, fixed_commitment] : zip_view(computed_vk.get_all(), fixed_vk.get_all())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size)
auto verifier_transcript = std::make_shared<bb::TranslatorFlavor::Transcript>();
verifier_transcript->load_proof(prover_transcript->export_proof());
verifier_transcript->template receive_from_prover<Fq>("init");
auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->proving_key);
auto verification_key = std::make_shared<TranslatorFlavor::VerificationKey>(proving_key->get_precomputed());
TranslatorVerifier verifier(verification_key, verifier_transcript);
bool verified = verifier.verify_proof(proof, x, translation_batching_challenge);
(void)checked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class TranslatorFlavor {
public:
DEFINE_COMPOUND_GET_ALL(PrecomputedEntities<DataType>, WitnessEntities<DataType>, ShiftedEntities<DataType>)

auto get_precomputed() const { return PrecomputedEntities<DataType>::get_all(); };
auto get_precomputed() { return PrecomputedEntities<DataType>::get_all(); };

/**
* @brief Getter for entities constructed by interleaving
Expand Down Expand Up @@ -749,22 +749,7 @@ class TranslatorFlavor {
}
};

/**
* @brief The proving key is responsible for storing the polynomials used by the prover.
*
*/
class ProvingKey {
public:
size_t circuit_size = 1UL << CONST_TRANSLATOR_LOG_N;
size_t log_circuit_size = CONST_TRANSLATOR_LOG_N;

ProverPolynomials polynomials; // storage for all polynomials evaluated by the prover
CommitmentKey commitment_key = CommitmentKey();

ProvingKey(const CommitmentKey& commitment_key = CommitmentKey())
: commitment_key(commitment_key)
{}
};
using PrecomputedData = PrecomputedData_<Polynomial, NUM_PRECOMPUTED_ENTITIES>;

/**
* @brief The verification key is responsible for storing the commitments to the precomputed (non-witnessk)
Expand All @@ -789,15 +774,15 @@ class TranslatorFlavor {
}
}

VerificationKey(const std::shared_ptr<ProvingKey>& proving_key)
VerificationKey(const PrecomputedData& precomputed)
{
this->log_circuit_size = CONST_TRANSLATOR_LOG_N;
this->num_public_inputs = 0;
this->pub_inputs_offset = 0;

for (auto [polynomial, commitment] :
zip_view(proving_key->polynomials.get_precomputed(), this->get_all())) {
commitment = proving_key->commitment_key.commit(polynomial);
CommitmentKey commitment_key{ 1UL << CONST_TRANSLATOR_LOG_N };
for (auto [polynomial, commitment] : zip_view(precomputed.polynomials, this->get_all())) {
commitment = commitment_key.commit(polynomial);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ TranslatorProver::TranslatorProver(const std::shared_ptr<TranslatorProvingKey>&
, key(key)
{
BB_BENCH();
if (!key->proving_key->commitment_key.initialized()) {
key->proving_key->commitment_key = CommitmentKey(key->proving_key->circuit_size);
if (!key->commitment_key.initialized()) {
key->commitment_key = CommitmentKey(key->dyadic_circuit_size);
}
}

Expand All @@ -41,16 +41,15 @@ void TranslatorProver::execute_preamble_round()
const auto SHIFTx2 = uint256_t(1) << (Flavor::NUM_LIMB_BITS * 2);
const auto SHIFTx3 = uint256_t(1) << (Flavor::NUM_LIMB_BITS * 3);
const size_t RESULT_ROW = Flavor::RESULT_ROW;
const auto accumulated_result =
BF(uint256_t(key->proving_key->polynomials.accumulators_binary_limbs_0[RESULT_ROW]) +
uint256_t(key->proving_key->polynomials.accumulators_binary_limbs_1[RESULT_ROW]) * SHIFT +
uint256_t(key->proving_key->polynomials.accumulators_binary_limbs_2[RESULT_ROW]) * SHIFTx2 +
uint256_t(key->proving_key->polynomials.accumulators_binary_limbs_3[RESULT_ROW]) * SHIFTx3);
const auto accumulated_result = BF(uint256_t(key->polynomials.accumulators_binary_limbs_0[RESULT_ROW]) +
uint256_t(key->polynomials.accumulators_binary_limbs_1[RESULT_ROW]) * SHIFT +
uint256_t(key->polynomials.accumulators_binary_limbs_2[RESULT_ROW]) * SHIFTx2 +
uint256_t(key->polynomials.accumulators_binary_limbs_3[RESULT_ROW]) * SHIFTx3);

relation_parameters.accumulated_result = { key->proving_key->polynomials.accumulators_binary_limbs_0[RESULT_ROW],
key->proving_key->polynomials.accumulators_binary_limbs_1[RESULT_ROW],
key->proving_key->polynomials.accumulators_binary_limbs_2[RESULT_ROW],
key->proving_key->polynomials.accumulators_binary_limbs_3[RESULT_ROW] };
relation_parameters.accumulated_result = { key->polynomials.accumulators_binary_limbs_0[RESULT_ROW],
key->polynomials.accumulators_binary_limbs_1[RESULT_ROW],
key->polynomials.accumulators_binary_limbs_2[RESULT_ROW],
key->polynomials.accumulators_binary_limbs_3[RESULT_ROW] };

// Send the accumulation result to the verifier, this value cannot be linked to the actual content of the op queue
// in practice (CIVC scenario) as we add a random, but genuine scalar mul operation to the op queue
Expand All @@ -65,7 +64,7 @@ void TranslatorProver::execute_preamble_round()
*/
void TranslatorProver::commit_to_witness_polynomial(Polynomial& polynomial, const std::string& label)
{
transcript->send_to_verifier(label, key->proving_key->commitment_key.commit(polynomial));
transcript->send_to_verifier(label, key->commitment_key.commit(polynomial));
}

/**
Expand All @@ -75,16 +74,14 @@ void TranslatorProver::commit_to_witness_polynomial(Polynomial& polynomial, cons
void TranslatorProver::execute_wire_and_sorted_constraints_commitments_round()
{

for (const auto& [wire, label] :
zip_view(key->proving_key->polynomials.get_wires(), commitment_labels.get_wires())) {
for (const auto& [wire, label] : zip_view(key->polynomials.get_wires(), commitment_labels.get_wires())) {

commit_to_witness_polynomial(wire, label);
}

// The ordered range constraints are of full circuit size.
for (const auto& [ordered_range_constraint, label] :
zip_view(key->proving_key->polynomials.get_ordered_range_constraints(),
commitment_labels.get_ordered_range_constraints())) {
for (const auto& [ordered_range_constraint, label] : zip_view(key->polynomials.get_ordered_range_constraints(),
commitment_labels.get_ordered_range_constraints())) {
commit_to_witness_polynomial(ordered_range_constraint, label);
}
}
Expand Down Expand Up @@ -128,9 +125,9 @@ void TranslatorProver::execute_grand_product_computation_round()
};
}
// Compute constraint permutation grand product
compute_grand_products<Flavor>(key->proving_key->polynomials, relation_parameters);
compute_grand_products<Flavor>(key->polynomials, relation_parameters);

commit_to_witness_polynomial(key->proving_key->polynomials.z_perm, commitment_labels.z_perm);
commit_to_witness_polynomial(key->polynomials.z_perm, commitment_labels.z_perm);
}

/**
Expand All @@ -150,10 +147,10 @@ void TranslatorProver::execute_relation_check_rounds()
gate_challenges[idx] = transcript->template get_challenge<FF>("Sumcheck:gate_challenge_" + std::to_string(idx));
}

const size_t circuit_size = key->proving_key->circuit_size;
const size_t circuit_size = key->dyadic_circuit_size;

Sumcheck sumcheck(circuit_size,
key->proving_key->polynomials,
key->polynomials,
transcript,
alpha,
gate_challenges,
Expand All @@ -166,7 +163,7 @@ void TranslatorProver::execute_relation_check_rounds()
// until we enter the PCS round
CommitmentKey ck(1 << (log_subgroup_size + 1));

zk_sumcheck_data = ZKData(key->proving_key->log_circuit_size, transcript, ck);
zk_sumcheck_data = ZKData(Flavor::CONST_TRANSLATOR_LOG_N, transcript, ck);

sumcheck_output = sumcheck.prove(zk_sumcheck_data);
}
Expand All @@ -185,23 +182,23 @@ void TranslatorProver::execute_pcs_rounds()
using PolynomialBatcher = GeminiProver_<Curve>::PolynomialBatcher;

// Check whether the commitment key has been deallocated and reinitialize it if necessary
auto& ck = key->proving_key->commitment_key;
auto& ck = key->commitment_key;
if (!ck.initialized()) {
ck = CommitmentKey(key->proving_key->circuit_size);
ck = CommitmentKey(key->dyadic_circuit_size);
}

SmallSubgroupIPA small_subgroup_ipa_prover(
zk_sumcheck_data, sumcheck_output.challenge, sumcheck_output.claimed_libra_evaluation, transcript, ck);
small_subgroup_ipa_prover.prove();

PolynomialBatcher polynomial_batcher(key->proving_key->circuit_size);
polynomial_batcher.set_unshifted(key->proving_key->polynomials.get_unshifted_without_interleaved());
polynomial_batcher.set_to_be_shifted_by_one(key->proving_key->polynomials.get_to_be_shifted());
polynomial_batcher.set_interleaved(key->proving_key->polynomials.get_interleaved(),
key->proving_key->polynomials.get_groups_to_be_interleaved());
PolynomialBatcher polynomial_batcher(key->dyadic_circuit_size);
polynomial_batcher.set_unshifted(key->polynomials.get_unshifted_without_interleaved());
polynomial_batcher.set_to_be_shifted_by_one(key->polynomials.get_to_be_shifted());
polynomial_batcher.set_interleaved(key->polynomials.get_interleaved(),
key->polynomials.get_groups_to_be_interleaved());

const OpeningClaim prover_opening_claim =
ShpleminiProver_<Curve>::prove(key->proving_key->circuit_size,
ShpleminiProver_<Curve>::prove(key->dyadic_circuit_size,
polynomial_batcher,
sumcheck_output.challenge,
ck,
Expand Down Expand Up @@ -232,7 +229,7 @@ HonkProof TranslatorProver::construct_proof()

// #ifndef __wasm__
// Free the commitment key
key->proving_key->commitment_key = CommitmentKey();
key->commitment_key = CommitmentKey();
// #endif

// Fiat-Shamir: alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class TranslatorProver {
using BF = typename Flavor::BF;
using Commitment = typename Flavor::Commitment;
using CommitmentKey = typename Flavor::CommitmentKey;
using ProvingKey = typename Flavor::ProvingKey;
using Polynomial = typename Flavor::Polynomial;
using CommitmentLabels = typename Flavor::CommitmentLabels;
using PCS = typename Flavor::PCS;
Expand Down
Loading