96 proj Tp, Tm, Pp[primes_num], Aux_Tp[3], Pm[primes_num], Aux_Tm[3], A;
107 uint8_t boolp = 0, boolm = 0;
112#ifdef ENABLE_CT_TESTING
113 VALGRIND_MAKE_MEM_DEFINED(Aux_Tp,
sizeof(
proj) * 3);
114 VALGRIND_MAKE_MEM_DEFINED(Aux_Tm,
sizeof(
proj) * 3);
115 VALGRIND_MAKE_MEM_DEFINED(&A,
sizeof(
proj));
116 VALGRIND_MAKE_MEM_DEFINED(&boolp,
sizeof(uint8_t));
117 VALGRIND_MAKE_MEM_DEFINED(&boolm,
sizeof(uint8_t));
118 VALGRIND_MAKE_MEM_DEFINED(&Tp,
sizeof(
proj));
119 VALGRIND_MAKE_MEM_DEFINED(Pp,
sizeof(
proj) * primes_num);
120 VALGRIND_MAKE_MEM_DEFINED(Pm,
sizeof(
proj) * primes_num);
126 clearpublicprimes(&Tp, &A);
127 clearpublicprimes(&Tm, &A);
129#ifdef ENABLE_CT_TESTING
130 memset(Aux_Tp, 0,
sizeof(
proj) * 3);
132 multiples(Aux_Tp, Tp, A);
133 if (fp_iszero(Aux_Tp[0].z) | fp_iszero(Aux_Tp[1].z) | fp_iszero(Aux_Tp[2].z))
136#ifdef ENABLE_CT_TESTING
137 memset(Aux_Tm, 0,
sizeof(
proj) * 3);
139 multiples(Aux_Tm, Tm, A);
140 if (fp_iszero(Aux_Tm[0].z) | fp_iszero(Aux_Tm[1].z) | fp_iszero(Aux_Tm[2].z))
144 proj_copy(&Pp[0], &Tp);
147 boolp &= (1 - fp_iszero(Pp[0].z)) | (1 - fp_iszero(Aux_Tp[0].z));
148 boolp &= (1 - fp_iszero(Pp[1].z)) | (1 - fp_iszero(Aux_Tp[1].z));
149 boolp &= (1 - fp_iszero(Pp[2].z)) | (1 - fp_iszero(Aux_Tp[2].z));
150 for (
j = 3;
j < (int)primes_num;
j++)
151 boolp &= (1 - fp_iszero(Pp[
j].z));
158 proj_copy(&Pm[0], &Tm);
162 boolm &= (1 - fp_iszero(Pm[0].z)) | (1 - fp_iszero(Aux_Tm[0].z));
163 boolm &= (1 - fp_iszero(Pm[1].z)) | (1 - fp_iszero(Aux_Tm[1].z));
164 boolm &= (1 - fp_iszero(Pm[2].z)) | (1 - fp_iszero(Aux_Tm[2].z));
165 for (
j = 3;
j < (int)primes_num;
j++)
166 boolm &= (1 - fp_iszero(Pm[
j].z));
171 }
while ((1 - boolp) | (1 - boolm));
173 fp_dec(u, (uint64_t *
const)u);
191 fp_set(seed, in->
seed);
195 clearpublicprimes(&Points[0], &A24);
196 clearpublicprimes(&Points[1], &A24);
199 for (int16_t
j =
batch_stop[primes_batches - 1] + 1;
j < primes_num;
j++)
206 int16_t unused[
batch_stop[primes_batches - 1] + 1];
212 for (e = 0; e <=
batch_stop[primes_batches - 1]; e++)
214#ifdef ENABLE_CT_TESTING
215 VALGRIND_MAKE_MEM_DEFINED(&u,
sizeof(int16_t));
216 VALGRIND_MAKE_MEM_DEFINED(&e,
sizeof(int16_t));
217 VALGRIND_MAKE_MEM_DEFINED(&w,
sizeof(int16_t));
222 int64_t mov = -int64mask_equal((int64_t)e, (int64_t)priv->
ells[w]);
238 for (u = 0; u <=
batch_stop[primes_batches - 1] - WOMBATKEYS; u++)
240 int16_t t = unused[u];
253 proj_copy(&Points[2], &Points[0]);
254 proj_copy(&Points[3], &Points[1]);
256 int16_t current_key = WOMBATKEYS - 1;
257 for (int16_t current_batch = primes_batches - 1; current_batch >= 0; current_batch--)
259 uint8_t inner_counter = 0;
262 proj_copy(&Points[0], &Points[2]);
263 proj_copy(&Points[1], &Points[3]);
282 uint16_t current_ell_index = priv->
ells[current_key];
283 uint64_t current_ell = lookup(current_ell_index,
primes);
285 int64_t direction = priv->
directions[current_key];
294 proj_cmov(&K, &Points[0], -int64mask_equal(direction, (int64_t)2));
295 proj_cmov(&K, &Points[1], 1 + int64mask_equal(direction, (int64_t)2));
306 proj_copy(&Points_[0], &Points[0]);
307 proj_copy(&Points_[1], &Points[1]);
308 proj_copy(&Points_[2], &Points[2]);
309 proj_copy(&Points_[3], &Points[3]);
312 if (current_key == 0)
315 xISOG_matryoshka(&A_, Points_, 0, &K, current_ell, lowerend_ell, upperend_ell);
320 xISOG_matryoshka(&A_, &Points_[2], 2, &K, current_ell, lowerend_ell, upperend_ell);
322 else if (current_batch == 0)
325 xISOG_matryoshka(&A_, Points_, 2, &K, current_ell, lowerend_ell, upperend_ell);
331 proj_cswap(&Points_[0], &Points_[1], -int64mask_equal(priv->
directions[current_key - 1], (int64_t)2));
332 xISOG_matryoshka(&A_, &Points_[1], 3, &K, current_ell, lowerend_ell, upperend_ell);
333 proj_cswap(&Points_[0], &Points_[1], -int64mask_equal(priv->
directions[current_key - 1], (int64_t)2));
337 xISOG_matryoshka(&A_, Points_, 4, &K, current_ell, lowerend_ell, upperend_ell);
341 proj_cmov(&A, &A_, -int64mask_nonzero(direction));
342 proj_cmov(&Points[0], &Points_[0], -int64mask_nonzero(direction));
343 proj_cmov(&Points[1], &Points_[1], -int64mask_nonzero(direction));
344 proj_cmov(&Points[2], &Points_[2], -int64mask_nonzero(direction));
345 proj_cmov(&Points[3], &Points_[3], -int64mask_nonzero(direction));
350 long long dac = lookup(current_ell_index,
primes_dac);
359 proj_cswap(&Points[0], &Points[1], -int64mask_equal(priv->
directions[current_key - 1], (int64_t)2));
361 proj_cswap(&Points[0], &Points[1], -int64mask_equal(priv->
directions[current_key - 1], (int64_t)2));
370 if (current_batch != 0)
381 fp_mul2(&A.x, (
const fp *)&A.z);