Skip to content

Commit f394c7f

Browse files
committed
Initial commit.
1 parent f426616 commit f394c7f

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/vdf_client.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ void CreateAndWriteProofTwoWeso(integer& D, form f, uint64_t iters, TwoWesolowsk
7777
WriteProof(iters, result, sock);
7878
}
7979

80+
form initial_form;
81+
char form_size[10];
82+
char form_a[10000];
83+
char form_b[10000];
84+
8085
void InitSession(tcp::socket& sock) {
8186
boost::system::error_code error;
8287

@@ -87,6 +92,24 @@ void InitSession(tcp::socket& sock) {
8792
disc_int_size = atoi(disc_size);
8893
boost::asio::read(sock, boost::asio::buffer(disc, disc_int_size), error);
8994

95+
boost::asio::read(sock, boost::asio::buffer(disc_size, 3), error);
96+
char prefix_len[3];
97+
for (int i = 0; i < 2; i++) {
98+
memset(prefix_len, 0x00, sizeof(prefix_len));
99+
boost::asio::read(sock, boost::asio::buffer(prefix_len, 1), error);
100+
int prefix_len_int = prefix_len[0] - '0';
101+
memset(form_size, 0x00, sizeof(form_size));
102+
boost::asio::read(sock, boost::asio::buffer(form_size, prefix_len_int), error);
103+
int form_size_int = atoi(form_size);
104+
if (i == 0) {
105+
memset(form_a, 0x00, sizeof(form_a));
106+
boost::asio::read(sock, boost::asio::buffer(form_a, form_size_int), error);
107+
} else {
108+
memset(form_b, 0x00, sizeof(form_b));
109+
boost::asio::read(sock, boost::asio::buffer(form_b, form_size_int), error);
110+
}
111+
}
112+
90113
if (error == boost::asio::error::eof)
91114
return ; // Connection closed cleanly by peer.
92115
else if (error)
@@ -145,9 +168,11 @@ void SessionFastAlgorithm(tcp::socket& sock) {
145168
try {
146169
integer D(disc);
147170
integer L=root(-D, 4);
148-
form f=form::generator(D);
149171
PrintInfo("Discriminant = " + to_string(D.impl));
150-
172+
integer init_A(form_a);
173+
integer init_B(form_b);
174+
form f = form::from_abd(init_A, init_B, D);
175+
PrintInfo("Initial form: " + to_string(f.a.impl) + " " + to_string(f.b.impl));
151176
std::vector<std::thread> threads;
152177
const bool multi_proc_machine = (std::thread::hardware_concurrency() >= 16) ? true : false;
153178
WesolowskiCallback* weso = new FastAlgorithmCallback(segments, D, multi_proc_machine);
@@ -230,8 +255,11 @@ void SessionTwoWeso(tcp::socket& sock) {
230255
try {
231256
integer D(disc);
232257
integer L=root(-D, 4);
233-
form f = form::generator(D);
234258
PrintInfo("Discriminant = " + to_string(D.impl));
259+
integer init_A(form_a);
260+
integer init_B(form_b);
261+
form f = form::from_abd(init_A, init_B, D);
262+
PrintInfo("Initial form: " + to_string(f.a.impl) + " " + to_string(f.b.impl));
235263

236264
// Tell client that I'm ready to get the challenges.
237265
boost::asio::write(sock, boost::asio::buffer("OK", 2));

0 commit comments

Comments
 (0)