+2020-10-15 Niels Möller <nisse@lysator.liu.se>
+
+ * testsuite/ecc-modinv-test.c (test_modulo): Allow invert function
+ to return a non-canonical representation.
+
2020-11-08 Niels Möller <nisse@lysator.liu.se>
Merge refactoring of ecc modulo and reduce functions.
|| mpn_cmp (xp, m->m, m->size) == 0;
}
+static int
+mod_eq_p (const struct ecc_modulo *m, const mp_limb_t *a, const mp_limb_t *b,
+ mp_limb_t *scratch) {
+ ecc_mod_sub (m, scratch, a, b);
+ return zero_p (m, scratch);
+}
+
#define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS)
#define COUNT 500
continue;
}
m->invert (m, ai, a, scratch);
- /* FIXME: Allow non-canonical representation, ai > m */
- if (mpn_cmp (ref, ai, m->size))
+ if (!mod_eq_p (m, ai, ref, scratch))
{
fprintf (stderr, "%s->invert failed (test %u, bit size %u):\n",
name, j, m->bit_size);
mpn_out_str (stderr, 16, ai, m->size);
fprintf (stderr, " (bad)\nr = ");
mpn_out_str (stderr, 16, ref, m->size);
+ printf ("\n");
abort ();
}