2014-08-23 Niels Möller <nisse@lysator.liu.se>
+ * ecc-mul-a.c (ecc_mul_a): Deleted INITIAL argument, all callers,
+ except the tests, pass 1. Updated all callers.
+ (table_init): Likewise deleted INITIAL.
+ * ecc.h (ecc_mul_a): Updated prototype.
+ * testsuite/ecc-mul-a-test.c (test_main): Deleted tests for
+ ecc_mul_a with INITIAL == 0.
+
* ecc-internal.h (struct ecc_curve): Reordered struct, moved
function pointers before pointers to bignum constants.
ecc_modq_mul (ecc, u2, rp, sinv);
/* Total storage: 5*ecc->size + ECC_MUL_A_ITCH (ecc->size) */
- ecc_mul_a (ecc, 1, P2, u2, pp, u2 + ecc->size);
+ ecc_mul_a (ecc, P2, u2, pp, u2 + ecc->size);
/* u1 = h / s, P1 = u1 * G */
ecc_hash (ecc, hp, length, digest);
#if ECC_MUL_A_WBITS == 0
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch)
{
unsigned i;
- ecc_a_to_j (ecc, initial, pj, p);
+ ecc_a_to_j (ecc, 1, pj, p);
mpn_zero (r, 3*ecc->size);
for (i = ecc->size, is_zero = 1; i-- > 0; )
static void
table_init (const struct ecc_curve *ecc,
mp_limb_t *table, unsigned bits,
- int initial, const mp_limb_t *p,
+ const mp_limb_t *p,
mp_limb_t *scratch)
{
unsigned size = 1 << bits;
unsigned j;
mpn_zero (TABLE(0), 3*ecc->size);
- ecc_a_to_j (ecc, initial, TABLE(1), p);
+ ecc_a_to_j (ecc, 1, TABLE(1), p);
for (j = 2; j < size; j += 2)
{
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch)
{
unsigned shift = bit_index % GMP_NUMB_BITS;
mp_limb_t w, bits;
- table_init (ecc, table, ECC_MUL_A_WBITS, initial, p, scratch_out);
+ table_init (ecc, table, ECC_MUL_A_WBITS, p, scratch_out);
w = np[limb_index];
bits = w >> shift;
assert (n->ecc == p->ecc);
assert (r->ecc == p->ecc);
- ecc_mul_a (p->ecc, 1, scratch, n->p, p->p, scratch + 3*size);
+ ecc_mul_a (p->ecc, scratch, n->p, p->p, scratch + 3*size);
ecc_j_to_a (r->ecc, 1, r->p, scratch, scratch + 3*size);
gmp_free_limbs (scratch, itch);
}
const mp_limb_t *np, mp_limb_t *scratch);
/* Computes N * P. The scalar N is the same as for ecc_mul_g. P is a
- non-zero point on the curve, in affine coordinates. Pass a non-zero
- INITIAL if the point coordinates have not previously been converted
- to Montgomery representation. Output R is a non-zero point, in
- Jacobian coordinates. */
+ non-zero point on the curve, in affine coordinates. Output R is a
+ non-zero point, in Jacobian coordinates. */
mp_size_t
ecc_mul_a_itch (const struct ecc_curve *ecc);
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch);
bench_mul_a (void *p)
{
struct ecc_ctx *ctx = (struct ecc_ctx *) p;
- ecc_mul_a (ctx->ecc, 1, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
+ ecc_mul_a (ctx->ecc, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
}
static void
mpn_zero (n, size);
n[0] = 1;
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
if (mpn_cmp (p, ecc->g, 2*size != 0))
die ("curve %d: ecc_mul_a with n = 1 failed.\n", ecc->bit_size);
- if (ecc->use_redc)
- {
- ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
- ecc_j_to_a (ecc, 1, p, p, scratch);
-
- if (mpn_cmp (p, ecc->g, 2*size != 0))
- die ("curve %d: ecc_mul_a with n = 1 and redc failed.\n", ecc->bit_size);
- }
for (n[0] = 2; n[0] <= 4; n[0]++)
{
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
test_ecc_mul_j (i, n[0], p);
- if (ecc->use_redc)
- {
- ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
- test_ecc_mul_j (i, n[0], p);
- }
}
/* (order - 1) * g = - g */
mpn_sub_1 (n, ecc->q, size, 1);
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
mpn_sub_n (p + size, ecc->p, p + size, size);
if (mpn_cmp (p, ecc->g, 2*size) != 0)
mpz_limbs_copy (n, r, size);
n[size - 1] %= ecc->q[size - 1];
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
ecc_mul_g (ecc, q, n, scratch);