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
3 changes: 0 additions & 3 deletions barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ bool ClientIVCAPI::verify([[maybe_unused]] const Flags& flags,
const auto proof = ClientIVC::Proof::from_file_msgpack(proof_path);
const auto vk = from_buffer<ClientIVC::VerificationKey>(read_file(vk_path));

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1335): Should be able to remove this.
vk.mega->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();

const bool verified = ClientIVC::verify(proof, vk);
return verified;
}
Expand Down
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ bool _verify(const bool ipa_accumulation,
srs::init_crs_factory({}, g2_data);

auto vk = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(read_file(vk_path)));
vk->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();
auto public_inputs = many_from_buffer<bb::fr>(read_file(public_inputs_path));
auto proof = many_from_buffer<bb::fr>(read_file(proof_path));
// concatenate public inputs and proof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ TEST_F(ClientIVCTests, VKIndependenceTest)
auto ivc_vk = ivc.get_vk();

// PCS verification keys will not match so set to null before comparing
ivc_vk.mega->pcs_verification_key = nullptr;
ivc_vk.eccvm->pcs_verification_key = nullptr;
ivc_vk.translator->pcs_verification_key = nullptr;

return ivc_vk;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ TEST_F(AcirAvm2RecursionConstraint, TestGenerateVKFromConstraintsWithoutWitness)
actual_vk = std::make_shared<OuterVerificationKey>(prover.proving_key->proving_key);
}

// PCS verification key adresses will in general not match so set to null before comparing
expected_vk->pcs_verification_key = nullptr;
actual_vk->pcs_verification_key = nullptr;

// Compare the VK constructed via running the IVC with the one constructed via mocking
EXPECT_EQ(*actual_vk.get(), *expected_vk.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ TEST_F(IvcRecursionConstraintTest, GenerateVK)
kernel_vk = std::make_shared<MegaFlavor::VerificationKey>(prover.proving_key->proving_key);
}

// PCS verification keys will not match so set to null before comparing
kernel_vk->pcs_verification_key = nullptr;
expected_kernel_vk->pcs_verification_key = nullptr;

EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
}

Expand Down Expand Up @@ -358,10 +354,6 @@ TEST_F(IvcRecursionConstraintTest, GenerateInitKernelVKFromConstraints)
kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
}

// PCS verification keys will not match so set to null before comparing
kernel_vk->pcs_verification_key = nullptr;
expected_kernel_vk->pcs_verification_key = nullptr;

// Compare the VK constructed via running the IVc with the one constructed via mocking
EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
}
Expand Down Expand Up @@ -411,10 +403,6 @@ TEST_F(IvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints)
kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
}

// PCS verification keys will not match so set to null before comparing
kernel_vk->pcs_verification_key = nullptr;
expected_kernel_vk->pcs_verification_key = nullptr;

// Compare the VK constructed via running the IVc with the one constructed via mocking
EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
}
Expand Down Expand Up @@ -472,10 +460,6 @@ TEST_F(IvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints)
kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
}

// PCS verification keys will not match so set to null before comparing
kernel_vk->pcs_verification_key = nullptr;
expected_kernel_vk->pcs_verification_key = nullptr;

// Compare the VK constructed via running the IVc with the one constructed via mocking
EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
}
Expand Down Expand Up @@ -534,4 +518,4 @@ TEST_F(IvcRecursionConstraintTest, BadRecursiveVerifierAppCircuitTest)
// Still expect this to be true since we don't aggregate pairing point objects correctly.
// If we fix aggregation, we should expect this test to fail.
EXPECT_TRUE(ivc->prove_and_verify());
}
}
9 changes: 0 additions & 9 deletions barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,6 @@ WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t cons
const auto proof = ClientIVC::Proof::from_msgpack_buffer(proof_buf);
const auto vk = from_buffer<ClientIVC::VerificationKey>(from_buffer<std::vector<uint8_t>>(vk_buf));

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1335): Should be able to remove this.
vk.mega->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();

*result = ClientIVC::verify(proof, vk);
}

Expand Down Expand Up @@ -337,12 +334,10 @@ WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t c
WASM_EXPORT void acir_verify_ultra_honk(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result)
{
using VerificationKey = UltraFlavor::VerificationKey;
using VerifierCommitmentKey = bb::VerifierCommitmentKey<curve::BN254>;
using Verifier = UltraVerifier_<UltraFlavor>;

auto proof = many_from_buffer<bb::fr>(from_buffer<std::vector<uint8_t>>(proof_buf));
auto verification_key = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(vk_buf));
verification_key->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

Verifier verifier{ verification_key };

Expand All @@ -352,12 +347,10 @@ WASM_EXPORT void acir_verify_ultra_honk(uint8_t const* proof_buf, uint8_t const*
WASM_EXPORT void acir_verify_ultra_keccak_honk(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result)
{
using VerificationKey = UltraKeccakFlavor::VerificationKey;
using VerifierCommitmentKey = bb::VerifierCommitmentKey<curve::BN254>;
using Verifier = UltraVerifier_<UltraKeccakFlavor>;

auto proof = many_from_buffer<bb::fr>(from_buffer<std::vector<uint8_t>>(proof_buf));
auto verification_key = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(vk_buf));
verification_key->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

Verifier verifier{ verification_key };

Expand Down Expand Up @@ -402,11 +395,9 @@ WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, uint8_
WASM_EXPORT void acir_honk_solidity_verifier(uint8_t const* proof_buf, uint8_t const* vk_buf, uint8_t** out)
{
using VerificationKey = UltraKeccakFlavor::VerificationKey;
using VerifierCommitmentKey = bb::VerifierCommitmentKey<curve::BN254>;

auto proof = many_from_buffer<bb::fr>(from_buffer<std::vector<uint8_t>>(proof_buf));
auto verification_key = from_buffer<VerificationKey>(vk_buf);
verification_key.pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

auto str = get_honk_solidity_verifier(&verification_key);
*out = to_heap_buffer(str);
Expand Down
12 changes: 4 additions & 8 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ class ECCVMFlavor {
public:
bool operator==(const VerificationKey&) const = default;

// IPA verification key requires one more point.
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key =
std::make_shared<VerifierCommitmentKey>(ECCVM_FIXED_SIZE + 1);

// Default construct the fixed VK that results from ECCVM_FIXED_SIZE
VerificationKey()
: VerificationKey_(ECCVM_FIXED_SIZE, /*num_public_inputs=*/0)
{
this->pub_inputs_offset = 0;
// IPA verification key requires one more point.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1025): make it so that PCSs inform the crs of
// how many points they need
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>(ECCVM_FIXED_SIZE + 1);

// Populate the commitments of the precomputed polynomials using the fixed VK data
for (auto [vk_commitment, fixed_commitment] :
Expand All @@ -773,10 +773,6 @@ class ECCVMFlavor {

VerificationKey(const std::shared_ptr<ProvingKey>& proving_key)
{
// IPA verification key requires one more point.
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1025): make it so that PCSs inform the crs of
// how many points they need
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>(ECCVM_FIXED_SIZE + 1);
this->circuit_size = 1UL << CONST_ECCVM_LOG_N;
this->log_circuit_size = CONST_ECCVM_LOG_N;
this->num_public_inputs = proving_key->num_public_inputs;
Expand Down
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class VerificationKey_ : public PrecomputedCommitments {
public:
using FF = typename VerifierCommitmentKey::Curve::ScalarField;
using Commitment = typename VerifierCommitmentKey::Commitment;
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;
FF_ circuit_size;
FF_ log_circuit_size;
FF_ num_public_inputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,18 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ {
class VerificationKey
: public VerificationKey_<FF, ECCVMFlavor::PrecomputedEntities<Commitment>, VerifierCommitmentKey> {
public:
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;

/**
* @brief Construct a new Verification Key with stdlib types from a provided native verification
* key
*
* @param builder
* @param native_key Native verification key from which to extract the precomputed commitments
*/

VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>(
pcs_verification_key = std::make_shared<VerifierCommitmentKey>(
builder, 1UL << CONST_ECCVM_LOG_N, native_key->pcs_verification_key);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1324): Remove `circuit_size` and
// `log_circuit_size` from MSGPACK and the verification key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ template <typename RecursiveFlavor> class RecursiveVerifierTest : public testing

using AggState = aggregation_state<OuterBuilder>;
using VerifierOutput = bb::stdlib::recursion::honk::UltraRecursiveVerifierOutput<OuterBuilder>;
using NativeVerifierCommitmentKey = typename InnerFlavor::VerifierCommitmentKey;
/**
* @brief Create a non-trivial arbitrary inner circuit, the proof of which will be recursively verified
*
Expand Down Expand Up @@ -223,11 +224,10 @@ template <typename RecursiveFlavor> class RecursiveVerifierTest : public testing
} else {
native_result = native_verifier.verify_proof(inner_proof);
}
auto pcs_verification_key = std::make_shared<typename InnerFlavor::VerifierCommitmentKey>();
bool result = pcs_verification_key->pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
NativeVerifierCommitmentKey pcs_vkey{};
bool result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
info("input pairing points result: ", result);
auto recursive_result = native_verifier.verification_key->verification_key->pcs_verification_key->pairing_check(
pairing_points.P0.get_value(), pairing_points.P1.get_value());
auto recursive_result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
EXPECT_EQ(recursive_result, native_result);

// Check 2: Ensure that the underlying native and recursive verification algorithms agree by ensuring
Expand Down Expand Up @@ -292,10 +292,9 @@ template <typename RecursiveFlavor> class RecursiveVerifierTest : public testing
EXPECT_FALSE(CircuitChecker::check(outer_circuit));
} else {
EXPECT_TRUE(CircuitChecker::check(outer_circuit));
auto pcs_verification_key = std::make_shared<typename InnerFlavor::VerifierCommitmentKey>();
NativeVerifierCommitmentKey pcs_vkey{};
AggState pairing_points = output.agg_obj;
bool result =
pcs_verification_key->pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
bool result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
EXPECT_FALSE(result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
*/
static void test_full_protogalaxy_recursive()
{
using NativeVerifierCommitmentKey = typename InnerFlavor::VerifierCommitmentKey;
// Create two arbitrary circuits for the first round of folding
InnerBuilder builder1;
create_function_circuit(builder1);
Expand Down Expand Up @@ -335,9 +336,8 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
// check that the result agrees.
InnerDeciderVerifier native_decider_verifier(verifier_accumulator);
auto native_result = native_decider_verifier.verify_proof(decider_proof);
auto recursive_result =
native_decider_verifier.accumulator->verification_key->pcs_verification_key->pairing_check(
pairing_points.P0.get_value(), pairing_points.P1.get_value());
NativeVerifierCommitmentKey pcs_vkey{};
auto recursive_result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
EXPECT_EQ(native_result, recursive_result);

if constexpr (!IsSimulator<OuterBuilder>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ template <IsRecursiveFlavor Flavor> class RecursiveDeciderVerificationKey_ {
auto native_honk_vk = std::make_shared<NativeVerificationKey>(
static_cast<uint64_t>(verification_key->circuit_size.get_value()),
static_cast<uint64_t>(verification_key->num_public_inputs.get_value()));
native_honk_vk->pcs_verification_key = verification_key->pcs_verification_key == nullptr
? std::make_shared<VerifierCommitmentKey>()
: verification_key->pcs_verification_key;
native_honk_vk->pub_inputs_offset = static_cast<uint64_t>(verification_key->pub_inputs_offset.get_value());
native_honk_vk->contains_pairing_point_accumulator = verification_key->contains_pairing_point_accumulator;
native_honk_vk->pairing_point_accumulator_public_input_indices =
Expand Down Expand Up @@ -153,4 +150,4 @@ template <IsRecursiveFlavor Flavor> class RecursiveDeciderVerificationKey_ {
return decider_vk;
}
};
} // namespace bb::stdlib::recursion::honk
} // namespace bb::stdlib::recursion::honk
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ template <typename BuilderType> class TranslatorRecursiveFlavor_ {
public:
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>(); // ?
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1324): Remove `circuit_size` and
// `log_circuit_size` from MSGPACK and the verification key.
this->circuit_size = FF{ 1UL << TranslatorFlavor::CONST_TRANSLATOR_LOG_N };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ template <typename RecursiveFlavor> class TranslatorRecursiveTests : public ::te

static void test_recursive_verification()
{
using NativeVerifierCommitmentKey = typename InnerFlavor::VerifierCommitmentKey;
// Add the same operations to the ECC op queue; the native computation is performed under the hood.
auto op_queue = create_op_queue(500);

Expand Down Expand Up @@ -97,8 +98,8 @@ template <typename RecursiveFlavor> class TranslatorRecursiveTests : public ::te
native_verifier_transcript->template receive_from_prover<InnerBF>("init");
InnerVerifier native_verifier(verification_key, native_verifier_transcript);
bool native_result = native_verifier.verify_proof(proof, evaluation_challenge_x, batching_challenge_v);
auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points.P0.get_value(),
pairing_points.P1.get_value());
NativeVerifierCommitmentKey pcs_vkey{};
auto recursive_result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
EXPECT_EQ(recursive_result, native_result);

auto recursive_manifest = verifier.transcript->get_manifest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ TYPED_TEST(FlavorSerializationTests, VerificationKeySerialization)
auto proving_key = std::make_shared<DeciderProvingKey>(builder);
VerificationKey original_vkey{ proving_key->proving_key };

// Set the pcs ptr to null since this will not be reconstructed correctly from buffer
original_vkey.pcs_verification_key = nullptr;

// Populate some non-zero values in the databus_propagation_data to ensure its being handled
if constexpr (IsMegaBuilder<Builder>) {
original_vkey.databus_propagation_data.app_return_data_commitment_pub_input_key =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ class MegaFlavor {

void set_metadata(const ProvingKey& proving_key)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
this->circuit_size = proving_key.circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = proving_key.num_public_inputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ template <typename BuilderType> class MegaRecursiveFlavor_ {
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->pcs_verification_key = native_key->pcs_verification_key;
this->circuit_size = FF::from_witness(builder, native_key->circuit_size);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ class UltraFlavor {
{}
VerificationKey(ProvingKey& proving_key)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
this->circuit_size = proving_key.circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = proving_key.num_public_inputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class UltraKeccakFlavor : public bb::UltraFlavor {
{}
VerificationKey(ProvingKey& proving_key)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
this->circuit_size = proving_key.circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = proving_key.num_public_inputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ template <typename BuilderType> class UltraRecursiveFlavor_ {
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
{
this->pcs_verification_key = native_key->pcs_verification_key;
this->circuit_size = FF::from_witness(builder, native_key->circuit_size);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1283): Use stdlib get_msb.
this->log_circuit_size = FF::from_witness(builder, numeric::get_msb(native_key->circuit_size));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class UltraRollupFlavor : public bb::UltraFlavor {
: contains_ipa_claim(proving_key.contains_ipa_claim)
, ipa_claim_public_input_indices(proving_key.ipa_claim_public_input_indices)
{
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
this->circuit_size = proving_key.circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = proving_key.num_public_inputs;
Expand Down
Loading