10 gmp_randinit_default (state
);
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 (ecc
));
25 ecc_mul_g (ecc
, p
, n
, scratch
);
26 ecc_j_to_a (ecc
, 1, 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_j (i
, n
[0], p
);
40 /* (order - 1) * g = - g */
41 mpn_sub_1 (n
, ecc
->q
, size
, 1);
42 ecc_mul_g (ecc
, p
, n
, scratch
);
43 ecc_j_to_a (ecc
, 1, p
, p
, scratch
);
44 mpn_sub_n (p
+ size
, ecc
->p
, p
+ size
, size
);
45 if (mpn_cmp (p
, ecc
->g
, 2*size
) != 0)
47 fprintf (stderr
, "ecc_mul_g with n = order - 1 failed.\n");
57 gmp_randclear (state
);