diff options
author | Niels Möller <nisse@lysator.liu.se> | 2022-10-02 17:56:16 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2022-10-02 17:56:16 +0200 |
commit | 76bd07fb0b2f6cbd1c649b4dd8b449090a566cca (patch) | |
tree | f35460f610b5a71001791a2ed20e879429fd5e51 | |
parent | 8a446577d5a8c5f978eae3b6cf1daacf2d17a142 (diff) | |
download | nettle-76bd07fb0b2f6cbd1c649b4dd8b449090a566cca.tar.gz |
Add benchmarking of modulo q inversion.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | examples/ecc-benchmark.c | 21 |
2 files changed, 19 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2022-10-02 Niels Möller <nisse@lysator.liu.se> + + * examples/ecc-benchmark.c (bench_curve): Add benchmarking of + modulo q inversion. + 2022-09-29 Niels Möller <nisse@lysator.liu.se> * ecc-ecdsa-verify.c (ecc_ecdsa_verify): Call ecc_mul_g and ecc_mul_a directly, not via diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c index 3ab269c7..7e857f80 100644 --- a/examples/ecc-benchmark.c +++ b/examples/ecc-benchmark.c @@ -159,11 +159,17 @@ bench_modq (void *p) } static void -bench_modinv (void *p) +bench_pinv (void *p) { struct ecc_ctx *ctx = (struct ecc_ctx *) p; ctx->ecc->p.invert (&ctx->ecc->p, ctx->rp, ctx->ap, ctx->tp); } +static void +bench_qinv (void *p) +{ + struct ecc_ctx *ctx = (struct ecc_ctx *) p; + ctx->ecc->q.invert (&ctx->ecc->p, ctx->rp, ctx->ap, ctx->tp); +} #if !NETTLE_USE_MINI_GMP static void @@ -239,7 +245,7 @@ static void bench_curve (const struct ecc_curve *ecc) { struct ecc_ctx ctx; - double modp, reduce, modq, modinv, modinv_gcd, modinv_powm, + double modp, reduce, modq, pinv, qinv, modinv_gcd, modinv_powm, dup_hh, add_hh, add_hhh, mul_g, mul_a; @@ -277,7 +283,8 @@ bench_curve (const struct ecc_curve *ecc) modq = time_function (bench_modq, &ctx); - modinv = time_function (bench_modinv, &ctx); + pinv = time_function (bench_pinv, &ctx); + qinv = time_function (bench_qinv, &ctx); #if !NETTLE_USE_MINI_GMP modinv_gcd = time_function (bench_modinv_gcd, &ctx); #else @@ -299,9 +306,9 @@ bench_curve (const struct ecc_curve *ecc) free (ctx.bp); free (ctx.tp); - printf ("%4d %6.4f %6.4f %6.4f %6.2f %6.3f %6.2f %6.3f %6.3f %6.3f %6.1f %6.1f\n", + printf ("%4d %6.4f %6.4f %6.4f %6.2f %6.2f %6.3f %6.2f %6.3f %6.3f %6.3f %6.1f %6.1f\n", ecc->p.bit_size, 1e6 * modp, 1e6 * reduce, 1e6 * modq, - 1e6 * modinv, 1e6 * modinv_gcd, 1e6 * modinv_powm, + 1e6 * pinv, 1e6 * qinv, 1e6 * modinv_gcd, 1e6 * modinv_powm, 1e6 * dup_hh, 1e6 * add_hh, 1e6 * add_hhh, 1e6 * mul_g, 1e6 * mul_a); } @@ -326,8 +333,8 @@ main (int argc UNUSED, char **argv UNUSED) unsigned i; time_init(); - printf ("%4s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s (us)\n", - "size", "modp", "reduce", "modq", "modinv", "mi_gcd", "mi_pow", + printf ("%4s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s (us)\n", + "size", "modp", "reduce", "modq", "pinv", "qinv", "mi_gcd", "mi_pow", "dup_hh", "add_hh", "ad_hhh", "mul_g", "mul_a"); for (i = 0; i < numberof (curves); i++) |