Skip to content

Commit

Permalink
Removed debug printout #296
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Feb 28, 2024
1 parent e238d66 commit ce23306
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 59 deletions.
16 changes: 2 additions & 14 deletions include/nil/crypto3/zk/commitments/polynomial/kzg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ namespace nil {
typename KZG::gt_value_type gt3 = algebra::double_miller_loop<typename KZG::curve_type>(A_1, A_2, B_1, B_2);
typename KZG::gt_value_type gt_4 = algebra::final_exponentiation<typename KZG::curve_type>(gt3);

auto left = algebra::pair_reduced<typename KZG::curve_type>(
proof,
params.verification_key - public_key.z * KZG::curve_type::template g2_type<>::value_type::one());

auto right = algebra::pair_reduced<typename KZG::curve_type>(
public_key.eval * KZG::curve_type::template g1_type<>::value_type::one() - public_key.commit,
KZG::curve_type::template g2_type<>::value_type::one());

return gt_4 == KZG::gt_value_type::one();
}
} // namespace algorithms
Expand Down Expand Up @@ -665,7 +657,6 @@ namespace nil {
return typename math::polynomial<typename KZGScheme::scalar_value_type>({{1}});
}
BOOST_ASSERT(this->get_V(result) * this->get_V(points) == this->get_V(merged_points));
//return zk::algorithms::create_polynom_by_zeros<KZGScheme>(result);
return this->get_V(result);
}

Expand Down Expand Up @@ -751,9 +742,7 @@ namespace nil {
for( auto const &it: this->_polys ){
auto k = it.first;
for (std::size_t i = 0; i < this->_z.get_batch_size(k); ++i) {
accum += factor * (
math::polynomial<typename KZGScheme::scalar_value_type>(this->_polys[k][i].coefficients()) -
this->get_U(k, i))/this->get_V(this->_points[k][i]);
accum += factor * ( math::polynomial<typename KZGScheme::scalar_value_type>( this->_polys[k][i].coefficients()) - this->get_U(k, i)) / this->get_V(this->_points[k][i]);
factor *= gamma;
}
}
Expand All @@ -774,8 +763,7 @@ namespace nil {
}
assert(accum * this->get_V(this->_merged_points) == right_side);
}*/
auto res_commit = nil::crypto3::zk::algorithms::commit_one<KZGScheme>(_params, accum);
return {this->_z, res_commit};
return {this->_z, nil::crypto3::zk::algorithms::commit_one<KZGScheme>(_params, accum)};
}

bool verify_eval(
Expand Down
18 changes: 0 additions & 18 deletions include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ namespace nil {
placeholder_proof<FieldType, ParamsType> process() {
PROFILE_PLACEHOLDER_SCOPE("Placeholder prover, total time");

std::cout << "proove_processor::preprocess" << std::endl;
std::cout << "appending to batch witnesses: " << std::endl;
for (auto &w: _polynomial_table->witnesses()) {
std::cout << w << std::endl;
}
std::cout << "appending to batch public inputs: " << std::endl;
for(auto &pi: _polynomial_table->public_inputs()) {
std::cout << pi << std::endl;
}
// 2. Commit witness columns and public_input columns
_commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table->witnesses());
_commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table->public_inputs());
Expand All @@ -151,7 +142,6 @@ namespace nil {
_proof.commitments[VARIABLE_VALUES_BATCH] = _commitment_scheme.commit(VARIABLE_VALUES_BATCH);
}
transcript(_proof.commitments[VARIABLE_VALUES_BATCH]);
std::cout << "vars commited and transcripted" << std::endl;

// 4. permutation_argument
{
Expand All @@ -167,7 +157,6 @@ namespace nil {
_F_dfs[1] = std::move(permutation_argument.F_dfs[1]);
_F_dfs[2] = std::move(permutation_argument.F_dfs[2]);
}
std::cout << "permutation argument prove_eval'ed" << std::endl;

// 5. lookup_argument
{
Expand All @@ -180,7 +169,6 @@ namespace nil {

_proof.commitments[PERMUTATION_BATCH] = _commitment_scheme.commit(PERMUTATION_BATCH);
transcript(_proof.commitments[PERMUTATION_BATCH]);
std::cout << "lookup argument evaluated, perm commited and transcripted" << std::endl;

// 6. circuit-satisfability

Expand All @@ -197,7 +185,6 @@ namespace nil {
mask_polynomial,
transcript
)[0];
std::cout << "gates prove_eval'ed" << std::endl;

/////TEST
#ifdef ZK_PLACEHOLDER_DEBUG_ENABLED
Expand All @@ -215,21 +202,16 @@ namespace nil {
_proof.commitments[QUOTIENT_BATCH] = T_commit(T_splitted_dfs);
}
transcript(_proof.commitments[QUOTIENT_BATCH]);
std::cout << "quotient batch commited and transcripted" << std::endl;

std::cout << "challenging for eval points" << std::endl;

// 8. Run evaluation proofs
_proof.eval_proof.challenge = transcript.template challenge<FieldType>();

std::cout << "proving with commitment scheme" << std::endl;
generate_evaluation_points();

{
PROFILE_PLACEHOLDER_SCOPE("commitment scheme proof eval time");
_proof.eval_proof.eval_proof = _commitment_scheme.proof_eval(transcript);
}
std::cout << "end" << std::endl;

return _proof;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ namespace nil {
const std::size_t constant_columns = table_description.constant_columns;
const std::size_t selector_columns = table_description.selector_columns;

std::cout << "=========== VERIFIER::PROCESS START ================" << std::endl;

transcript::fiat_shamir_heuristic_sequential<transcript_hash_type> transcript(std::vector<std::uint8_t>({}));

transcript(preprocessed_public_data.common_data.vk.constraint_system_with_params_hash);
Expand Down Expand Up @@ -318,8 +316,7 @@ namespace nil {
std::map<std::size_t, typename commitment_scheme_type::commitment_type> commitments = proof.commitments;
commitments[FIXED_VALUES_BATCH] = preprocessed_public_data.common_data.commitments.fixed_values;
if (!commitment_scheme.verify_eval( proof.eval_proof.eval_proof, commitments, transcript )) {
std::cout << "commitment verify failed, SKIPPING" << std::endl;
// return false;
return false;
}

// 10. final check
Expand Down Expand Up @@ -347,7 +344,6 @@ namespace nil {
// Z is polynomial -1, 0 ...., 0, 1
typename FieldType::value_type Z_at_challenge = preprocessed_public_data.common_data.Z.evaluate(challenge);
if (F_consolidated != Z_at_challenge * T_consolidated) {
std::cout << "Final evaluation failed" << std::endl;
return false;
}
return true;
Expand Down
22 changes: 0 additions & 22 deletions include/nil/crypto3/zk/transcript/fiat_shamir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,10 @@ namespace nil {
typedef Hash hash_type;

fiat_shamir_heuristic_sequential() : state(hash<hash_type>({0})) {
std::cout << "default transcript constructor " << this << std::endl;
}

template<typename InputRange>
fiat_shamir_heuristic_sequential(const InputRange &r) : state(hash<hash_type>(r)) {
std::cout << "transcript " << this << "constructed with [[[" << std::endl;
for(auto x = r.begin(); x!= r.end(); ++x) {
std::cout << std::hex << std::setw(2) << std::setfill('0') << int(*x);
}
std::cout << std::endl << "]]]" << std::endl;
}

template<typename InputIterator>
void dump_buffer(InputIterator first, InputIterator last)
{
std::cout << "updating transcript " << this << " with [[[" << std::endl;
for(auto x = first; x!= last; ++x) {
std::cout << std::hex << std::setw(2) << std::setfill('0') << int(*x);
}
std::cout << std::endl << "]]]" << std::endl;
}

template<typename InputIterator>
Expand All @@ -164,15 +148,13 @@ namespace nil {
template<typename InputRange>
void operator()(const InputRange &r) {
auto acc_convertible = hash<hash_type>(state);
dump_buffer(r.begin(), r.end());
state = accumulators::extract::hash<hash_type>(
hash<hash_type>(r, static_cast<accumulator_set<hash_type> &>(acc_convertible)));
}

template<typename InputIterator>
void operator()(InputIterator first, InputIterator last) {
auto acc_convertible = hash<hash_type>(state);
dump_buffer(first, last);
state = accumulators::extract::hash<hash_type>(
hash<hash_type>(first, last, static_cast<accumulator_set<hash_type> &>(acc_convertible)));
}
Expand All @@ -185,8 +167,6 @@ namespace nil {
state = hash<hash_type>(state);
nil::marshalling::status_type status;
nil::crypto3::multiprecision::cpp_int raw_result = nil::marshalling::pack(state, status);

std::cout << "transcript " << this << " challenged for: " << std::hex << raw_result << std::endl;
return raw_result;
}

Expand All @@ -196,8 +176,6 @@ namespace nil {
state = hash<hash_type>(state);
nil::marshalling::status_type status;
Integral raw_result = nil::marshalling::pack(state, status);

std::cout << "transcript " << this << " int_challenged for: " << std::hex << raw_result << std::endl;
return raw_result;
}

Expand Down

0 comments on commit ce23306

Please sign in to comment.