Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit

Permalink
Temporarily add logging of challenges, to catch a bug on CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
martun committed May 7, 2024
1 parent a96e603 commit 1386e08
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion include/nil/crypto3/zk/transcript/fiat_shamir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,22 @@ namespace nil {

template<typename InputRange>
void operator()(const InputRange &r) {
std::cout << "Next inputs are: ";
for (const auto& f: r)
std::cout << (int)f << " ";
std::cout << std::endl << std::endl;

auto acc_convertible = hash<hash_type>(state);
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) {
std::cout << "Next inputs iter are:";
for (InputIterator it = first; it != last; ++it)
std::cout << *it << " ";
std::cout << std::endl << std::endl;
auto acc_convertible = hash<hash_type>(state);
state = accumulators::extract::hash<hash_type>(
hash<hash_type>(first, last, static_cast<accumulator_set<hash_type> &>(acc_convertible)));
Expand All @@ -171,6 +180,7 @@ 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 << "Next challenge is " << raw_result << std::endl;
return raw_result;
}

Expand All @@ -180,6 +190,7 @@ namespace nil {
state = hash<hash_type>(state);
nil::marshalling::status_type status;
Integral raw_result = nil::marshalling::pack(state, status);
std::cout << "Next int_challenge is " << raw_result << std::endl;
return raw_result;
}

Expand All @@ -189,6 +200,7 @@ namespace nil {
std::array<typename Field::value_type, N> challenges() {

std::array<typename Field::value_type, N> result;
std::cout << "Next challenges are: " << std::endl;
for (auto &ch : result) {
ch = challenge<Field>();
}
Expand Down Expand Up @@ -258,7 +270,9 @@ namespace nil {

template<typename Field>
typename Field::value_type challenge() {
return sponge.squeeze();
typename Field::value_type result = sponge.squeeze();
std::cout << "Next Poseidon challenge is "<< result << std::endl;
return result;
}

template<typename Integral>
Expand All @@ -276,13 +290,15 @@ namespace nil {
intermediate_result = intermediate_result / 0x100;
bytes_to_fill -= 2;
}
std::cout << "Next Poseidon int challenge is "<< result << std::endl;
return result;
}

template<typename Field, std::size_t N>
std::array<typename Field::value_type, N> challenges() {

std::array<typename Field::value_type, N> result;
std::cout << "Next Poseidon challenges are: " << std::endl;
for (auto &ch : result) {
ch = challenge<Field>();
}
Expand Down

0 comments on commit 1386e08

Please sign in to comment.