diff options
Diffstat (limited to 'src/util/crypto_ecc_dlog.c')
-rw-r--r-- | src/util/crypto_ecc_dlog.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/crypto_ecc_dlog.c b/src/util/crypto_ecc_dlog.c index 29cba3336..1254a036e 100644 --- a/src/util/crypto_ecc_dlog.c +++ b/src/util/crypto_ecc_dlog.c | |||
@@ -467,6 +467,29 @@ GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
467 | 467 | ||
468 | 468 | ||
469 | /** | 469 | /** |
470 | * Obtain a random scalar for point multiplication on the curve and | ||
471 | * its multiplicative inverse. | ||
472 | * | ||
473 | * @param edc calculation context for ECC operations | ||
474 | * @param[out] r set to a random scalar on the curve | ||
475 | * @param[out] r_inv set to the multiplicative inverse of @a r | ||
476 | */ | ||
477 | void | ||
478 | GNUNET_CRYPTO_ecc_rnd_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | ||
479 | gcry_mpi_t *r, | ||
480 | gcry_mpi_t *r_inv) | ||
481 | { | ||
482 | gcry_mpi_t n; | ||
483 | |||
484 | *r = GNUNET_CRYPTO_ecc_random_mod_n (edc); | ||
485 | /* r_inv = n - r = - r */ | ||
486 | *r_inv = gcry_mpi_new (0); | ||
487 | n = gcry_mpi_ec_get_mpi ("n", edc->ctx, 1); | ||
488 | gcry_mpi_sub (*r_inv, n, *r); | ||
489 | } | ||
490 | |||
491 | |||
492 | /** | ||
470 | * Free a point value returned by the API. | 493 | * Free a point value returned by the API. |
471 | * | 494 | * |
472 | * @param p point to free | 495 | * @param p point to free |