10 gmp_randinit_default (rands);
13 for (i = 0; ecc_curves[i]; i++)
15 const struct ecc_curve *ecc = ecc_curves[i];
16 mp_size_t size = ecc_size (ecc);
17 mp_limb_t *p = xalloc_limbs (ecc_size_j (ecc));
18 mp_limb_t *q = xalloc_limbs (ecc_size_j (ecc));
19 mp_limb_t *n = xalloc_limbs (size);
20 mp_limb_t *scratch = xalloc_limbs (ecc->mul_g_itch);
25 ecc->mul_g (ecc, p, n, scratch);
26 ecc->h_to_a (ecc, 0, p, p, scratch);
28 if (mpn_cmp (p, ecc->g, 2*size != 0))
30 fprintf (stderr, "ecc->mul_g with n = 1 failed.\n");
34 for (n[0] = 2; n[0] <= 4; n[0]++)
36 ecc->mul_g (ecc, p, n, scratch);
37 test_ecc_mul_h (i, n[0], p);
40 /* (order - 1) * g = - g */
41 mpn_sub_1 (n, ecc->q.m, size, 1);
42 ecc->mul_g (ecc, p, n, scratch);
43 ecc->h_to_a (ecc, 0, p, p, scratch);
44 if (ecc->p.bit_size == 255)
45 /* For edwards curves, - (x,y ) == (-x, y). FIXME: Swap x and
46 y, to get identical negation? */
47 mpn_sub_n (p, ecc->p.m, p, size);
49 mpn_sub_n (p + size, ecc->p.m, p + size, size);
50 if (mpn_cmp (p, ecc->g, 2*size) != 0)
52 fprintf (stderr, "ecc->mul_g with n = order - 1 failed.\n");
62 gmp_randclear (rands);