diff --git a/src/1weso_test.cpp b/src/1weso_test.cpp index 808ed9d2..35225a8f 100644 --- a/src/1weso_test.cpp +++ b/src/1weso_test.cpp @@ -3,6 +3,7 @@ #include "verifier.h" #include +#include int segments = 7; int thread_count = 3; @@ -45,10 +46,10 @@ int main(int argc, char const* argv[]) try fast_algorithm = false; uint64_t iter = iter_multiplier; - OneWesolowskiCallback weso(D, iter); + OneWesolowskiCallback weso(D, f, iter); FastStorage* fast_storage = nullptr; std::thread vdf_worker(repeated_square, f, D, L, &weso, fast_storage, std::ref(stopped)); - Proof const proof = ProveOneWesolowski(iter, D, &weso, stopped); + Proof const proof = ProveOneWesolowski(iter, D, f, &weso, stopped); stopped = true; vdf_worker.join(); @@ -67,7 +68,7 @@ int main(int argc, char const* argv[]) try ); VerifyWesolowskiProof(D, x_init, y, proof_form, iter, is_valid); std::cout << "Verify result: " << is_valid << "\n"; - return is_valid ? 0 : 1; + assert(is_valid); } catch (std::exception const& e) { std::cerr << "Exception " << e.what() << '\n'; diff --git a/src/callback.h b/src/callback.h index 4dd8ac3c..d9520db7 100644 --- a/src/callback.h +++ b/src/callback.h @@ -72,7 +72,7 @@ class WesolowskiCallback :public INUDUPLListener { class OneWesolowskiCallback: public WesolowskiCallback { public: - OneWesolowskiCallback(integer& D, uint64_t wanted_iter) : WesolowskiCallback(D) { + OneWesolowskiCallback(integer& D, form& f, uint64_t wanted_iter) : WesolowskiCallback(D) { uint32_t k, l; this->wanted_iter = wanted_iter; if (wanted_iter >= (1 << 16)) { @@ -84,7 +84,6 @@ class OneWesolowskiCallback: public WesolowskiCallback { kl = k * l; uint64_t space_needed = wanted_iter / (k * l) + 100; forms.reset(new form[space_needed]); - form f = form::generator(D); forms[0] = f; } diff --git a/src/vdf.h b/src/vdf.h index 8e95b52f..f8f92999 100644 --- a/src/vdf.h +++ b/src/vdf.h @@ -239,13 +239,12 @@ void repeated_square(form f, const integer& D, const integer& L, #endif } -Proof ProveOneWesolowski(uint64_t iters, integer& D, OneWesolowskiCallback* weso, +Proof ProveOneWesolowski(uint64_t iters, integer& D, form f, OneWesolowskiCallback* weso, std::atomic& stopped) { while (weso->iterations < iters) { this_thread::sleep_for(1s); } - form f = form::generator(D); Segment sg( /*start=*/0, /*length=*/iters, diff --git a/src/vdf_client.cpp b/src/vdf_client.cpp index 3756d0df..185dbf6a 100644 --- a/src/vdf_client.cpp +++ b/src/vdf_client.cpp @@ -60,8 +60,8 @@ void CreateAndWriteProof(ProverManager& pm, uint64_t iteration, std::atomic& stop_signal, tcp::socket& sock) { - Proof result = ProveOneWesolowski(iters, D, weso, stop_signal); +void CreateAndWriteProofOneWeso(uint64_t iters, integer& D, form f, OneWesolowskiCallback* weso, std::atomic& stop_signal, tcp::socket& sock) { + Proof result = ProveOneWesolowski(iters, D, f, weso, stop_signal); if (stop_signal) { PrintInfo("Got stop signal before completing the proof!"); return ; @@ -216,9 +216,12 @@ void SessionOneWeso(tcp::socket& sock) { try { integer D(disc); integer L=root(-D, 4); - form f=form::generator(D); PrintInfo("Discriminant = " + to_string(D.impl)); - + integer init_A(form_a); + PrintInfo("Initial A: " + to_string(init_A.impl)); + integer init_B(form_b); + PrintInfo("Initial B: " + to_string(init_B.impl)); + form f = form::from_abd(init_A, init_B, D); // Tell client that I'm ready to get the challenges. boost::asio::write(sock, boost::asio::buffer("OK", 2)); @@ -228,10 +231,10 @@ void SessionOneWeso(tcp::socket& sock) { return; } std::atomic stopped(false); - WesolowskiCallback* weso = new OneWesolowskiCallback(D, iter); + WesolowskiCallback* weso = new OneWesolowskiCallback(D, f, iter); FastStorage* fast_storage = NULL; std::thread vdf_worker(repeated_square, f, std::ref(D), std::ref(L), weso, fast_storage, std::ref(stopped)); - std::thread th_prover(CreateAndWriteProofOneWeso, iter, std::ref(D), (OneWesolowskiCallback*)weso, std::ref(stopped), std::ref(sock)); + std::thread th_prover(CreateAndWriteProofOneWeso, iter, std::ref(D), f, (OneWesolowskiCallback*)weso, std::ref(stopped), std::ref(sock)); iter = ReadIteration(sock); while (iter != 0) { std::cout << "Warning: did not receive stop signal\n";