From ce2330697bce083e2aced15e6a33481192dd4290 Mon Sep 17 00:00:00 2001 From: Vasiliy Olekhov Date: Wed, 28 Feb 2024 14:22:18 +0300 Subject: [PATCH] Removed debug printout #296 --- .../crypto3/zk/commitments/polynomial/kzg.hpp | 16 ++------------ .../systems/plonk/placeholder/prover.hpp | 18 --------------- .../systems/plonk/placeholder/verifier.hpp | 6 +---- .../nil/crypto3/zk/transcript/fiat_shamir.hpp | 22 ------------------- 4 files changed, 3 insertions(+), 59 deletions(-) diff --git a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp index 7f919d996..85f6dc223 100644 --- a/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp +++ b/include/nil/crypto3/zk/commitments/polynomial/kzg.hpp @@ -198,14 +198,6 @@ namespace nil { typename KZG::gt_value_type gt3 = algebra::double_miller_loop(A_1, A_2, B_1, B_2); typename KZG::gt_value_type gt_4 = algebra::final_exponentiation(gt3); - auto left = algebra::pair_reduced( - proof, - params.verification_key - public_key.z * KZG::curve_type::template g2_type<>::value_type::one()); - - auto right = algebra::pair_reduced( - 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 @@ -665,7 +657,6 @@ namespace nil { return typename math::polynomial({{1}}); } BOOST_ASSERT(this->get_V(result) * this->get_V(points) == this->get_V(merged_points)); - //return zk::algorithms::create_polynom_by_zeros(result); return this->get_V(result); } @@ -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(this->_polys[k][i].coefficients()) - - this->get_U(k, i))/this->get_V(this->_points[k][i]); + accum += factor * ( math::polynomial( this->_polys[k][i].coefficients()) - this->get_U(k, i)) / this->get_V(this->_points[k][i]); factor *= gamma; } } @@ -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(_params, accum); - return {this->_z, res_commit}; + return {this->_z, nil::crypto3::zk::algorithms::commit_one(_params, accum)}; } bool verify_eval( diff --git a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp index fa8a4477f..8331d867b 100644 --- a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp +++ b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp @@ -134,15 +134,6 @@ namespace nil { placeholder_proof 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()); @@ -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 { @@ -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 { @@ -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 @@ -197,7 +185,6 @@ namespace nil { mask_polynomial, transcript )[0]; - std::cout << "gates prove_eval'ed" << std::endl; /////TEST #ifdef ZK_PLACEHOLDER_DEBUG_ENABLED @@ -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(); - 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; } diff --git a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp index f4707df38..cfe91b6a5 100644 --- a/include/nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp +++ b/include/nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp @@ -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(std::vector({})); transcript(preprocessed_public_data.common_data.vk.constraint_system_with_params_hash); @@ -318,8 +316,7 @@ namespace nil { std::map 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 @@ -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; diff --git a/include/nil/crypto3/zk/transcript/fiat_shamir.hpp b/include/nil/crypto3/zk/transcript/fiat_shamir.hpp index f31cb1118..c8887f150 100644 --- a/include/nil/crypto3/zk/transcript/fiat_shamir.hpp +++ b/include/nil/crypto3/zk/transcript/fiat_shamir.hpp @@ -134,26 +134,10 @@ namespace nil { typedef Hash hash_type; fiat_shamir_heuristic_sequential() : state(hash({0})) { - std::cout << "default transcript constructor " << this << std::endl; } template fiat_shamir_heuristic_sequential(const InputRange &r) : state(hash(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 - 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 @@ -164,7 +148,6 @@ namespace nil { template void operator()(const InputRange &r) { auto acc_convertible = hash(state); - dump_buffer(r.begin(), r.end()); state = accumulators::extract::hash( hash(r, static_cast &>(acc_convertible))); } @@ -172,7 +155,6 @@ namespace nil { template void operator()(InputIterator first, InputIterator last) { auto acc_convertible = hash(state); - dump_buffer(first, last); state = accumulators::extract::hash( hash(first, last, static_cast &>(acc_convertible))); } @@ -185,8 +167,6 @@ namespace nil { state = hash(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; } @@ -196,8 +176,6 @@ namespace nil { state = hash(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; }