Skip to content

Commit

Permalink
Merge pull request #78 from NilFoundation/77-profiling-interfaces-update
Browse files Browse the repository at this point in the history
Interfaces updated and call example
  • Loading branch information
nkaskov authored Oct 13, 2022
2 parents 91e44a3 + cd3f7ab commit cb0bed6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/profiling_plonk_circuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ namespace nil {
using placeholder_params = zk::snark::placeholder_params<FieldType, ArithmetizationParams, Hash, Hash, Lambda>;
using types = zk::snark::detail::placeholder_policy<FieldType, placeholder_params>;
using ArithmetizationType = zk::snark::plonk_constraint_system<FieldType, ArithmetizationParams>;
using preprocessed_public_data_type = typename zk::snark::placeholder_public_preprocessor<
FieldType, placeholder_params>::preprocessed_data_type;

template<typename Container, typename ContainerIt>
static bool is_last_element(const Container &c, ContainerIt it) {
return it == (std::cend(c) - 1);
}

static void print_variable(std::ostream &os, const nil::crypto3::zk::snark::plonk_variable<FieldType> &var,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
std::size_t rotation_idx =
std::find(std::cbegin(public_preprocessed_data.common_data.columns_rotations.at(var.index)),
std::cend(public_preprocessed_data.common_data.columns_rotations.at(var.index)),
Expand All @@ -72,7 +74,7 @@ namespace nil {
print_term(std::ostream &os,
const Vars &vars,
VarsIt it,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
if (it != std::cend(vars)) {
if (!is_last_element(vars, it)) {
os << "mulmod(";
Expand All @@ -95,7 +97,7 @@ namespace nil {
print_terms(std::ostream &os,
const Terms &terms,
TermsIt it,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
if (it != std::cend(terms)) {
os << "mstore("
"add(gate_params, CONSTRAINT_EVAL_OFFSET),"
Expand Down Expand Up @@ -127,7 +129,7 @@ namespace nil {
static void
print_constraint(std::ostream &os,
const typename nil::crypto3::zk::snark::plonk_constraint<FieldType> &constraint,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
os << "mstore(add(gate_params, CONSTRAINT_EVAL_OFFSET), 0)" << std::endl;
print_terms(os, constraint.terms, std::cbegin(constraint.terms), public_preprocessed_data);
}
Expand Down Expand Up @@ -187,7 +189,7 @@ namespace nil {
static void print_gate(std::ostream &os,
const nil::crypto3::zk::snark::plonk_gate<
FieldType, nil::crypto3::zk::snark::plonk_constraint<FieldType>> &gate,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
os << "mstore(add(gate_params, GATE_EVAL_OFFSET), 0)" << std::endl;
for (auto &constraint : gate.constraints) {
print_constraint(os, constraint, public_preprocessed_data);
Expand All @@ -199,14 +201,14 @@ namespace nil {
}

static void process(std::ostream &os, const zk::blueprint<ArithmetizationType> &bp,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
for (const auto &gate : bp.gates()) {
print_gate(os, gate, public_preprocessed_data);
}
}

static void process_split(const zk::blueprint<ArithmetizationType> &bp,
const typename types::preprocessed_public_data_type &public_preprocessed_data) {
const preprocessed_public_data_type &public_preprocessed_data) {
for (const auto &gate : bp.gates()) {
std::ofstream gate_out;
gate_out.open("gate" + std::to_string(gate.selector_index) + ".txt");
Expand Down
1 change: 1 addition & 0 deletions test/test_plonk_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ namespace nil {
public_preprocessed_data, proof, bp, fri_params);

#ifdef BLUEPRINT_PLONK_PROFILING_ENABLED
profiling_plonk_circuit<BlueprintFieldType, ArithmetizationParams, Hash, Lambda>::process(std::cout, bp, public_preprocessed_data);
profiling(assignments);
#endif
if(verification_result) {
Expand Down

0 comments on commit cb0bed6

Please sign in to comment.