-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: representation of a grumpkin verifier commitment key inside a b…
…n254 circuit (#6593) This PR creates a representation of Grumpkin `VerifierCommitmentKey` inside a bn254 circuit and ensure consistency with native part. This is necessary to enable IPA verification in the recursive setting. I took a minimalist approach and excluded the `pippenger_runtime_state` as we will initially do MSMs in the IPA verifier via `batch_mul`. This is because pippenger needs to be rewritten to be usable in a recursive settings. I also restricted access to the `VerifierSrs` via member functions in the native `VerifierCommitmentKey`. This work is a step towards the ECCVM recursive verifier.
- Loading branch information
1 parent
2d10848
commit 1d84975
Showing
8 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
barretenberg/cpp/src/barretenberg/eccvm_recursion/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
barretenberg_module(eccvm_recursion stdlib_circuit_builders commitment_schemes stdlib_primitives) |
42 changes: 42 additions & 0 deletions
42
barretenberg/cpp/src/barretenberg/eccvm_recursion/verifier_commitment_key.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
#include "barretenberg/commitment_schemes/verification_key.hpp" | ||
#include "barretenberg/stdlib/primitives/curves/bn254.hpp" | ||
#include "barretenberg/stdlib/primitives/group/cycle_group.hpp" | ||
namespace bb { | ||
|
||
/** | ||
* @brief Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit | ||
* | ||
* @tparam Builder | ||
*/ | ||
template <typename Builder> class VerifierCommitmentKey<stdlib::bn254<Builder>> { | ||
using Commitment = stdlib::cycle_group<Builder>; | ||
|
||
public: | ||
/** | ||
* @brief Construct a new Verifier Commitment Key object from its native counterpart. instantiated on Grumpkin. This | ||
* will potentially be part of the ECCVMRecursiveFlavor once implemented. | ||
* | ||
* @details The Grumpkin SRS points will be initialised as constants in the circuit but might be subsequently turned | ||
* into constant witnesses to make operations in the circuit more efficient. | ||
*/ | ||
VerifierCommitmentKey([[maybe_unused]] Builder* builder, | ||
size_t num_points, | ||
std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>>& native_pcs_verification_key) | ||
: first_g1(Commitment(native_pcs_verification_key->get_first_g1())) | ||
{ | ||
|
||
auto* native_points = native_pcs_verification_key->get_monomial_points(); | ||
for (size_t i = 0; i < num_points; i++) { | ||
monomial_points.emplace_back(Commitment(native_points[i])); | ||
} | ||
} | ||
|
||
Commitment get_first_g1() { return first_g1; } | ||
std::vector<Commitment> get_monomial_points() { return monomial_points; } | ||
|
||
private: | ||
Commitment first_g1; | ||
std::vector<Commitment> monomial_points; | ||
}; | ||
} // namespace bb |
42 changes: 42 additions & 0 deletions
42
barretenberg/cpp/src/barretenberg/eccvm_recursion/verifier_commitment_key.test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#include "barretenberg/eccvm_recursion/verifier_commitment_key.hpp" | ||
#include <gtest/gtest.h> | ||
namespace bb { | ||
template <typename Builder> class RecursiveVeriferCommitmentKeyTest : public testing::Test { | ||
public: | ||
using native_VK = VerifierCommitmentKey<curve::Grumpkin>; | ||
using VK = VerifierCommitmentKey<stdlib::bn254<Builder>>; | ||
static void SetUpTestSuite() | ||
{ | ||
srs::init_crs_factory("../srs_db/ignition"); | ||
srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); | ||
} | ||
|
||
/** | ||
* @brief Instantiante a recursive verifier commitment key from a Grumpkin native key and check consistency. | ||
* | ||
*/ | ||
static void test_equality() | ||
{ | ||
size_t num_points = 4096; | ||
Builder builder; | ||
auto native_vk = std::make_shared<native_VK>(num_points); | ||
auto recursive_vk = std::make_shared<VK>(&builder, num_points, native_vk); | ||
EXPECT_EQ(native_vk->get_first_g1(), recursive_vk->get_first_g1().get_value()); | ||
auto* native_monomial_points = native_vk->get_monomial_points(); | ||
auto recursive_monomial_points = recursive_vk->get_monomial_points(); | ||
for (size_t i = 0; i < num_points; i++) { | ||
EXPECT_EQ(native_monomial_points[i], recursive_monomial_points[i].get_value()); | ||
} | ||
} | ||
}; | ||
|
||
using Builders = testing::Types<UltraCircuitBuilder, GoblinUltraCircuitBuilder>; | ||
|
||
TYPED_TEST_SUITE(RecursiveVeriferCommitmentKeyTest, Builders); | ||
|
||
TYPED_TEST(RecursiveVeriferCommitmentKeyTest, EqualityTest) | ||
{ | ||
TestFixture::test_equality(); | ||
}; | ||
} // namespace bb |