-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cg/arithmetization #296
Cg/arithmetization #296
Changes from 7 commits
dd316cd
9612767
c1c96e0
2d75d12
6219a18
0f9a9d2
96b3aa2
8ef9404
f89ff3a
0a04cac
75dee62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.vscode | ||
result | ||
node_modules | ||
.yarn/cache | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,9 +111,9 @@ std::shared_ptr<bonk::proving_key> StandardHonkComposerHelper<CircuitConstructor | |
StandardHonkComposerHelper::compute_proving_key_base(circuit_constructor, plonk::ComposerType::STANDARD_HONK); | ||
|
||
// Compute sigma polynomials (we should update that late) | ||
compute_standard_honk_sigma_permutations<CircuitConstructor::program_width>(circuit_constructor, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since in this PR there is now an array |
||
circuit_proving_key.get()); | ||
compute_standard_honk_id_polynomials<CircuitConstructor::program_width>(circuit_proving_key.get()); | ||
compute_standard_honk_sigma_permutations<CircuitConstructor::num_wires>(circuit_constructor, | ||
circuit_proving_key.get()); | ||
compute_standard_honk_id_polynomials<CircuitConstructor::num_wires>(circuit_proving_key.get()); | ||
|
||
compute_first_and_last_lagrange_polynomials(circuit_proving_key.get()); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ class StandardPlonkComposer { | |
|
||
// Leaving it in for now just in case | ||
bool contains_recursive_proof = false; | ||
static constexpr size_t program_width = STANDARD_WIDTH; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to minimize footprint, at least for now. |
||
static constexpr size_t program_width = StandardCircuitConstructor::program_width; | ||
|
||
/**Standard methods*/ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#pragma once | ||
#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" | ||
#include "barretenberg/transcript/transcript.hpp" | ||
namespace plonk { | ||
class settings_base { | ||
|
@@ -11,6 +12,7 @@ class settings_base { | |
|
||
class standard_settings : public settings_base { | ||
public: | ||
using Arithmetization = arithmetization::Standard; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a temporary measure, will refactor more fully with flavor work. |
||
static constexpr size_t num_challenge_bytes = 16; | ||
static constexpr transcript::HashType hash_type = transcript::HashType::PedersenBlake3s; | ||
static constexpr size_t program_width = 3; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <cstddef> | ||
|
||
namespace arithmetization { | ||
|
||
template <size_t _num_wires, size_t _num_selectors> struct Arithmetization { | ||
static constexpr size_t num_wires = _num_wires; | ||
static constexpr size_t num_selectors = _num_selectors; | ||
// Note: For even greater modularity, in each instantiation we could specify a list of components here, where a | ||
// component is a meaningful collection of functions for creating gates, as in: | ||
// | ||
// struct Component { | ||
// using Arithmetic = component::Arithmetic3Wires; | ||
// using RangeConstraints = component::Base4Accumulators or component::GenPerm or... | ||
// using LooupTables = component::Plookup4Wire or component::CQ8Wire or... | ||
// ... | ||
// }; | ||
// | ||
// We should only do this if it becomes necessary or convenient. | ||
}; | ||
|
||
// These are not magic numbers and they should not be written with global constants. These paraters are not accessible | ||
// through clearly named static class members. | ||
using Standard = Arithmetization<3, 5>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To me a magic number is any number that appears without a name (and without explanation) in the code. Aside from being unexplained, they are also unsearchable. We should find a way to avoid global constants AND hard coded numbers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But everywhere outside of this file this numbers should be accessed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added argument comments to clarify as in |
||
using Turbo = Arithmetization<4, 11>; | ||
|
||
} // namespace arithmetization |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
#pragma once | ||
#include "barretenberg/proof_system/composer/composer_base.hpp" | ||
#include "barretenberg/proof_system/arithmetization/arithmetization.hpp" | ||
#include "barretenberg/proof_system/arithmetization/gate_data.hpp" | ||
#include "barretenberg/ecc/curves/bn254/fr.hpp" | ||
#include <utility> | ||
|
||
using namespace bonk; | ||
namespace bonk { | ||
static constexpr uint32_t DUMMY_TAG = 0; | ||
|
||
template <size_t program_width_> class CircuitConstructorBase { | ||
template <typename Arithmetization> class CircuitConstructorBase { | ||
public: | ||
static constexpr size_t program_width = program_width_; | ||
static constexpr size_t num_wires = Arithmetization::num_wires; | ||
// Keeping num_wires, at least temporarily, for backward compatibility | ||
static constexpr size_t program_width = Arithmetization::num_wires; | ||
static constexpr size_t num_selectors = Arithmetization::num_selectors; | ||
// TODO(Cody): selector names are used by composer helper. They can therefore be specified through the proving | ||
// system flavor. Getting rid of this also lets us get rid of the weird constructor that's uses the selector names | ||
// functions | ||
std::vector<std::string> selector_names_; | ||
size_t num_gates = 0; | ||
// TODO(#216)(Adrian): It would be better to store an array of size program_width_ | ||
// to make the composer agnostic of the wire name. | ||
std::vector<uint32_t> w_l; | ||
std::vector<uint32_t> w_r; | ||
std::vector<uint32_t> w_o; | ||
std::vector<uint32_t> w_4; | ||
|
||
std::array<std::vector<uint32_t>, num_wires> wires; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
std::array<std::vector<barretenberg::fr>, num_selectors> selectors; | ||
|
||
std::vector<uint32_t> public_inputs; | ||
std::vector<barretenberg::fr> variables; | ||
// index of next variable in equivalence class (=REAL_VARIABLE if you're last) | ||
|
@@ -33,8 +37,6 @@ template <size_t program_width_> class CircuitConstructorBase { | |
// DOCTODO(#231): replace with the relevant wiki link. | ||
std::map<uint32_t, uint32_t> tau; | ||
|
||
size_t num_selectors; | ||
std::vector<std::vector<barretenberg::fr>> selectors; | ||
numeric::random::Engine* rand_engine = nullptr; | ||
bool _failed = false; | ||
std::string _err; | ||
|
@@ -46,10 +48,8 @@ template <size_t program_width_> class CircuitConstructorBase { | |
// Cody: This is used by compute_wire_copy_cycles in Plonk. | ||
// enum WireType { LEFT = 0U, RIGHT = (1U << 30U), OUTPUT = (1U << 31U), FOURTH = 0xc0000000 }; | ||
|
||
CircuitConstructorBase(std::vector<std::string> selector_names, size_t num_selectors = 0, size_t size_hint = 0) | ||
CircuitConstructorBase(std::vector<std::string> selector_names, size_t size_hint = 0) | ||
: selector_names_(std::move(selector_names)) | ||
, num_selectors(num_selectors) | ||
, selectors(num_selectors) | ||
{ | ||
for (auto& p : selectors) { | ||
p.reserve(size_hint); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The settings.json and c_cpp_properties.json files are already being tracked, so having this in the .gitignore does nothing. We should probably remove these and .gitignore to allow people overriding code-workspace settings, or we should start using multiple code-workspace files.