From 689407c36d9d1c04771682be769a8d29950c2d93 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 1 May 2019 19:56:08 +0200 Subject: [PATCH] Rename ristretto_from_uniform() to ristretto_from_hash() --- .../crypto_core/ed25519/core_ristretto255.c | 8 +++--- .../crypto_core/ed25519/ref10/ed25519_ref10.c | 2 +- .../include/sodium/crypto_core_ristretto255.h | 8 +++--- .../include/sodium/private/ed25519_ref10.h | 2 +- test/default/core_ristretto255.c | 26 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/libsodium/crypto_core/ed25519/core_ristretto255.c b/src/libsodium/crypto_core/ed25519/core_ristretto255.c index 94cc64a6..57305bef 100644 --- a/src/libsodium/crypto_core/ed25519/core_ristretto255.c +++ b/src/libsodium/crypto_core/ed25519/core_ristretto255.c @@ -60,9 +60,9 @@ crypto_core_ristretto255_sub(unsigned char *r, } int -crypto_core_ristretto255_from_uniform(unsigned char *p, const unsigned char *r) +crypto_core_ristretto255_from_hash(unsigned char *p, const unsigned char *r) { - ristretto255_from_uniform(p, r); + ristretto255_from_hash(p, r); return 0; } @@ -135,9 +135,9 @@ crypto_core_ristretto255_nonreducedscalarbytes(void) } size_t -crypto_core_ristretto255_uniformbytes(void) +crypto_core_ristretto255_hashbytes(void) { - return crypto_core_ristretto255_UNIFORMBYTES; + return crypto_core_ristretto255_HASHBYTES; } size_t diff --git a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c index e7b44493..cd215f2b 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c +++ b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c @@ -2815,7 +2815,7 @@ ristretto255_elligator(ge25519_p3 *p, const fe25519 t) } void -ristretto255_from_uniform(unsigned char s[32], const unsigned char r[64]) +ristretto255_from_hash(unsigned char s[32], const unsigned char r[64]) { fe25519 r0, r1; ge25519_cached p1_cached; diff --git a/src/libsodium/include/sodium/crypto_core_ristretto255.h b/src/libsodium/include/sodium/crypto_core_ristretto255.h index 33522b07..9d642e33 100644 --- a/src/libsodium/include/sodium/crypto_core_ristretto255.h +++ b/src/libsodium/include/sodium/crypto_core_ristretto255.h @@ -12,9 +12,9 @@ extern "C" { SODIUM_EXPORT size_t crypto_core_ristretto255_bytes(void); -#define crypto_core_ristretto255_UNIFORMBYTES 64 +#define crypto_core_ristretto255_HASHBYTES 64 SODIUM_EXPORT -size_t crypto_core_ristretto255_uniformbytes(void); +size_t crypto_core_ristretto255_hashbytes(void); #define crypto_core_ristretto255_SCALARBYTES 32 SODIUM_EXPORT @@ -39,8 +39,8 @@ int crypto_core_ristretto255_sub(unsigned char *r, __attribute__ ((nonnull)); SODIUM_EXPORT -int crypto_core_ristretto255_from_uniform(unsigned char *p, - const unsigned char *r) +int crypto_core_ristretto255_from_hash(unsigned char *p, + const unsigned char *r) __attribute__ ((nonnull)); SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/private/ed25519_ref10.h b/src/libsodium/include/sodium/private/ed25519_ref10.h index 5f7e67e3..344905b7 100644 --- a/src/libsodium/include/sodium/private/ed25519_ref10.h +++ b/src/libsodium/include/sodium/private/ed25519_ref10.h @@ -118,7 +118,7 @@ int ristretto255_frombytes(ge25519_p3 *h, const unsigned char *s); void ristretto255_p3_tobytes(unsigned char *s, const ge25519_p3 *h); -void ristretto255_from_uniform(unsigned char s[32], const unsigned char r[64]); +void ristretto255_from_hash(unsigned char s[32], const unsigned char r[64]); /* The set of scalars is \Z/l diff --git a/test/default/core_ristretto255.c b/test/default/core_ristretto255.c index 159cb8e3..a52ef8b7 100644 --- a/test/default/core_ristretto255.c +++ b/test/default/core_ristretto255.c @@ -62,7 +62,7 @@ tv1(void) static void tv2(void) { - static const char *uniform_hex[] = { + static const char *hash_hex[] = { "5d1be09e3d0c82fc538112490e35701979d99e06ca3e2b5b54bffe8b4dc772c1" "4d98b696a1bbfb5ca32c436cc61c16563790306c79eaca7705668b47dffe5bb6", @@ -90,13 +90,13 @@ tv2(void) size_t i; s = (unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES); - u = (unsigned char *) sodium_malloc(crypto_core_ristretto255_UNIFORMBYTES); + u = (unsigned char *) sodium_malloc(crypto_core_ristretto255_HASHBYTES); hex = (char *) sodium_malloc(crypto_core_ristretto255_BYTES * 2 + 1); - for (i = 0; i < sizeof uniform_hex / sizeof uniform_hex[0]; i++) { - sodium_hex2bin(u, crypto_core_ristretto255_UNIFORMBYTES, uniform_hex[i], - crypto_core_ristretto255_UNIFORMBYTES * 2 + 1, + for (i = 0; i < sizeof hash_hex / sizeof hash_hex[0]; i++) { + sodium_hex2bin(u, crypto_core_ristretto255_HASHBYTES, hash_hex[i], + crypto_core_ristretto255_HASHBYTES * 2 + 1, NULL, NULL, NULL); - crypto_core_ristretto255_from_uniform(s, u); + crypto_core_ristretto255_from_hash(s, u); sodium_bin2hex(hex, crypto_core_ristretto255_BYTES * 2 + 1, s, crypto_core_ristretto255_BYTES); printf("%s\n", hex); @@ -120,7 +120,7 @@ tv3(void) unsigned char *r_inv = (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES); unsigned char *ru = - (unsigned char *) sodium_malloc(crypto_core_ristretto255_UNIFORMBYTES); + (unsigned char *) sodium_malloc(crypto_core_ristretto255_HASHBYTES); unsigned char *s = (unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES); unsigned char *s_ = @@ -138,10 +138,10 @@ tv3(void) if (crypto_scalarmult_ristretto255(s, l, s) == 0) { printf("s*l != inf (1)\n"); } - randombytes_buf(ru, crypto_core_ristretto255_UNIFORMBYTES); - if (crypto_core_ristretto255_from_uniform(s, ru) != 0 || + randombytes_buf(ru, crypto_core_ristretto255_HASHBYTES); + if (crypto_core_ristretto255_from_hash(s, ru) != 0 || crypto_core_ristretto255_is_valid_point(s) != 1) { - printf("crypto_core_ristretto255_from_uniform() failed\n"); + printf("crypto_core_ristretto255_from_hash() failed\n"); } if (crypto_scalarmult_ristretto255(s2, l, s) == 0) { printf("s*l != inf (2)\n"); @@ -184,12 +184,12 @@ main(void) assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ristretto255_scalarbytes()); assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ristretto255_nonreducedscalarbytes()); assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES >= crypto_core_ristretto255_SCALARBYTES); - assert(crypto_core_ristretto255_UNIFORMBYTES == crypto_core_ristretto255_uniformbytes()); - assert(crypto_core_ristretto255_UNIFORMBYTES >= crypto_core_ristretto255_BYTES); + assert(crypto_core_ristretto255_HASHBYTES == crypto_core_ristretto255_hashbytes()); + assert(crypto_core_ristretto255_HASHBYTES >= crypto_core_ristretto255_BYTES); assert(crypto_core_ristretto255_BYTES == crypto_core_ed25519_BYTES); assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ed25519_SCALARBYTES); assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ed25519_NONREDUCEDSCALARBYTES); - assert(crypto_core_ristretto255_UNIFORMBYTES > crypto_core_ed25519_UNIFORMBYTES); + assert(crypto_core_ristretto255_HASHBYTES >= 2 * crypto_core_ed25519_UNIFORMBYTES); printf("OK\n");