-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
builds w UCB inheritance w new arith
- Loading branch information
1 parent
0370b13
commit 4362af5
Showing
15 changed files
with
368 additions
and
113 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
barretenberg/cpp/src/barretenberg/honk/composer/databus_composer.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,99 @@ | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <gtest/gtest.h> | ||
|
||
#include "barretenberg/common/log.hpp" | ||
#include "barretenberg/honk/composer/ultra_composer.hpp" | ||
#include "barretenberg/honk/proof_system/ultra_prover.hpp" | ||
#include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" | ||
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" | ||
|
||
using namespace proof_system::honk; | ||
|
||
namespace test_ultra_honk_composer { | ||
|
||
namespace { | ||
auto& engine = numeric::random::get_debug_engine(); | ||
} | ||
|
||
class DataBusComposerTests : public ::testing::Test { | ||
protected: | ||
static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } | ||
|
||
using Curve = curve::BN254; | ||
using FF = Curve::ScalarField; | ||
using Point = Curve::AffineElement; | ||
using CommitmentKey = pcs::CommitmentKey<Curve>; | ||
|
||
/** | ||
* @brief Generate a simple test circuit with some ECC op gates and conventional arithmetic gates | ||
* | ||
* @param builder | ||
*/ | ||
void generate_test_circuit(auto& builder) | ||
{ | ||
// Add some ecc op gates | ||
for (size_t i = 0; i < 3; ++i) { | ||
auto point = Point::one() * FF::random_element(); | ||
auto scalar = FF::random_element(); | ||
builder.queue_ecc_mul_accum(point, scalar); | ||
} | ||
builder.queue_ecc_eq(); | ||
|
||
// Add some conventional gates that utilize public inputs | ||
for (size_t i = 0; i < 10; ++i) { | ||
FF a = FF::random_element(); | ||
FF b = FF::random_element(); | ||
FF c = FF::random_element(); | ||
FF d = a + b + c; | ||
uint32_t a_idx = builder.add_public_variable(a); | ||
uint32_t b_idx = builder.add_variable(b); | ||
uint32_t c_idx = builder.add_variable(c); | ||
uint32_t d_idx = builder.add_variable(d); | ||
|
||
builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, FF(1), FF(1), FF(1), FF(-1), FF(0) }); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Construct and a verify a Honk proof | ||
* | ||
*/ | ||
bool construct_and_verify_honk_proof(auto& composer, auto& builder) | ||
{ | ||
auto instance = composer.create_instance(builder); | ||
auto prover = composer.create_prover(instance); | ||
auto verifier = composer.create_verifier(instance); | ||
auto proof = prover.construct_proof(); | ||
bool verified = verifier.verify_proof(proof); | ||
|
||
return verified; | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Test proof construction/verification for a circuit with ECC op gates, public inputs, and basic arithmetic | ||
* gates | ||
* @note We simulate op queue interactions with a previous circuit so the actual circuit under test utilizes an op queue | ||
* with non-empty 'previous' data. This avoid complications with zero-commitments etc. | ||
* | ||
*/ | ||
TEST_F(DataBusComposerTests, SingleCircuit) | ||
{ | ||
auto op_queue = std::make_shared<proof_system::ECCOpQueue>(); | ||
|
||
// Add mock data to op queue to simulate interaction with a previous circuit | ||
op_queue->populate_with_mock_initital_data(); | ||
|
||
auto builder = proof_system::GoblinUltraCircuitBuilder(op_queue); | ||
|
||
generate_test_circuit(builder); | ||
|
||
auto composer = GoblinUltraComposer(); | ||
|
||
// Construct and verify Honk proof | ||
auto honk_verified = construct_and_verify_honk_proof(composer, builder); | ||
EXPECT_TRUE(honk_verified); | ||
} | ||
|
||
} // namespace test_ultra_honk_composer |
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
Oops, something went wrong.