Skip to content

Commit

Permalink
Updating intermediates generation, and fix some const correctness (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: Raphael Toledo <contact@raphael-toledo.com>
  • Loading branch information
arvidn and rrtoledo committed Oct 6, 2022
1 parent 67740cc commit fce4f1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/nucomp.h
Expand Up @@ -51,7 +51,7 @@ typedef struct qfb
typedef qfb qfb_t[1];

// From Antic using Flint (works!)
void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, mpz_t& D, mpz_t& L)
void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, mpz_t const& D, mpz_t const& L)
{
mpz_t a1, a2, c2, ca, cb, cc, k, s, sp, ss, m, t, u2, v1, v2;

Expand Down Expand Up @@ -192,7 +192,7 @@ void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, mpz_t& D, mpz_t& L)
}

// a = b * c
void nucomp_form(form &a, form &b, form &c, integer &D, integer &L) {
void nucomp_form(form &a, form const& b, form const& c, integer const& D, integer const& L) {
qfb fr, fr2, fr3;

*fr.a = *a.a.impl;
Expand Down
18 changes: 12 additions & 6 deletions src/prover_slow.h
Expand Up @@ -30,7 +30,7 @@ uint64_t GetBlock(uint64_t i, uint64_t k, uint64_t T, integer& B) {

form GenerateWesolowski(form &y, form &x_init,
integer &D, PulmarkReducer& reducer,
std::vector<form>& intermediates,
std::vector<form> const& intermediates,
uint64_t num_iterations,
uint64_t k, uint64_t l) {
integer B = GetB(D, x_init, y);
Expand Down Expand Up @@ -82,20 +82,26 @@ std::vector<uint8_t> ProveSlow(integer& D, form& x, uint64_t num_iterations) {
integer L = root(-D, 4);
PulmarkReducer reducer;
form y = form::from_abd(x.a, x.b, D);
std::vector<form> intermediates;
int k, l;
int d_bits = D.num_bits();

int k, l;
ApproximateParameters(num_iterations, l, k);
if (k <= 0) k = 1;
if (l <= 0) l = 1;
for (int i = 0; i < num_iterations; i++) {
if (i % (k * l) == 0) {
intermediates.push_back(y);
int const kl = k * l;

uint64_t const size_vec = (num_iterations + kl - 1) / kl;
std::vector<form> intermediates(size_vec);
form* cursor = intermediates.data();
for (uint64_t i = 0; i < num_iterations; i++) {
if (i % kl == 0) {
*cursor = y;
++cursor;
}
nudupl_form(y, y, D, L);
reducer.reduce(y);
}

form proof = GenerateWesolowski(y, x, D, reducer, intermediates, num_iterations, k, l);
std::vector<uint8_t> result = SerializeForm(y, d_bits);
std::vector<uint8_t> proof_bytes = SerializeForm(proof, d_bits);
Expand Down

0 comments on commit fce4f1b

Please sign in to comment.