1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Rename ristretto_from_uniform() to ristretto_from_hash()

This commit is contained in:
Frank Denis 2019-05-01 19:56:08 +02:00
parent 38ebbac336
commit 689407c36d
5 changed files with 23 additions and 23 deletions

View File

@ -60,9 +60,9 @@ crypto_core_ristretto255_sub(unsigned char *r,
} }
int 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; return 0;
} }
@ -135,9 +135,9 @@ crypto_core_ristretto255_nonreducedscalarbytes(void)
} }
size_t size_t
crypto_core_ristretto255_uniformbytes(void) crypto_core_ristretto255_hashbytes(void)
{ {
return crypto_core_ristretto255_UNIFORMBYTES; return crypto_core_ristretto255_HASHBYTES;
} }
size_t size_t

View File

@ -2815,7 +2815,7 @@ ristretto255_elligator(ge25519_p3 *p, const fe25519 t)
} }
void 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; fe25519 r0, r1;
ge25519_cached p1_cached; ge25519_cached p1_cached;

View File

@ -12,9 +12,9 @@ extern "C" {
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_ristretto255_bytes(void); size_t crypto_core_ristretto255_bytes(void);
#define crypto_core_ristretto255_UNIFORMBYTES 64 #define crypto_core_ristretto255_HASHBYTES 64
SODIUM_EXPORT SODIUM_EXPORT
size_t crypto_core_ristretto255_uniformbytes(void); size_t crypto_core_ristretto255_hashbytes(void);
#define crypto_core_ristretto255_SCALARBYTES 32 #define crypto_core_ristretto255_SCALARBYTES 32
SODIUM_EXPORT SODIUM_EXPORT
@ -39,8 +39,8 @@ int crypto_core_ristretto255_sub(unsigned char *r,
__attribute__ ((nonnull)); __attribute__ ((nonnull));
SODIUM_EXPORT SODIUM_EXPORT
int crypto_core_ristretto255_from_uniform(unsigned char *p, int crypto_core_ristretto255_from_hash(unsigned char *p,
const unsigned char *r) const unsigned char *r)
__attribute__ ((nonnull)); __attribute__ ((nonnull));
SODIUM_EXPORT SODIUM_EXPORT

View File

@ -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_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 The set of scalars is \Z/l

View File

@ -62,7 +62,7 @@ tv1(void)
static void static void
tv2(void) tv2(void)
{ {
static const char *uniform_hex[] = { static const char *hash_hex[] = {
"5d1be09e3d0c82fc538112490e35701979d99e06ca3e2b5b54bffe8b4dc772c1" "5d1be09e3d0c82fc538112490e35701979d99e06ca3e2b5b54bffe8b4dc772c1"
"4d98b696a1bbfb5ca32c436cc61c16563790306c79eaca7705668b47dffe5bb6", "4d98b696a1bbfb5ca32c436cc61c16563790306c79eaca7705668b47dffe5bb6",
@ -90,13 +90,13 @@ tv2(void)
size_t i; size_t i;
s = (unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES); 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); hex = (char *) sodium_malloc(crypto_core_ristretto255_BYTES * 2 + 1);
for (i = 0; i < sizeof uniform_hex / sizeof uniform_hex[0]; i++) { for (i = 0; i < sizeof hash_hex / sizeof hash_hex[0]; i++) {
sodium_hex2bin(u, crypto_core_ristretto255_UNIFORMBYTES, uniform_hex[i], sodium_hex2bin(u, crypto_core_ristretto255_HASHBYTES, hash_hex[i],
crypto_core_ristretto255_UNIFORMBYTES * 2 + 1, crypto_core_ristretto255_HASHBYTES * 2 + 1,
NULL, NULL, NULL); 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, sodium_bin2hex(hex, crypto_core_ristretto255_BYTES * 2 + 1,
s, crypto_core_ristretto255_BYTES); s, crypto_core_ristretto255_BYTES);
printf("%s\n", hex); printf("%s\n", hex);
@ -120,7 +120,7 @@ tv3(void)
unsigned char *r_inv = unsigned char *r_inv =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES); (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
unsigned char *ru = unsigned char *ru =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_UNIFORMBYTES); (unsigned char *) sodium_malloc(crypto_core_ristretto255_HASHBYTES);
unsigned char *s = unsigned char *s =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES); (unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES);
unsigned char *s_ = unsigned char *s_ =
@ -138,10 +138,10 @@ tv3(void)
if (crypto_scalarmult_ristretto255(s, l, s) == 0) { if (crypto_scalarmult_ristretto255(s, l, s) == 0) {
printf("s*l != inf (1)\n"); printf("s*l != inf (1)\n");
} }
randombytes_buf(ru, crypto_core_ristretto255_UNIFORMBYTES); randombytes_buf(ru, crypto_core_ristretto255_HASHBYTES);
if (crypto_core_ristretto255_from_uniform(s, ru) != 0 || if (crypto_core_ristretto255_from_hash(s, ru) != 0 ||
crypto_core_ristretto255_is_valid_point(s) != 1) { 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) { if (crypto_scalarmult_ristretto255(s2, l, s) == 0) {
printf("s*l != inf (2)\n"); 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_SCALARBYTES == crypto_core_ristretto255_scalarbytes());
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ristretto255_nonreducedscalarbytes()); assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ristretto255_nonreducedscalarbytes());
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES >= crypto_core_ristretto255_SCALARBYTES); assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES >= crypto_core_ristretto255_SCALARBYTES);
assert(crypto_core_ristretto255_UNIFORMBYTES == crypto_core_ristretto255_uniformbytes()); assert(crypto_core_ristretto255_HASHBYTES == crypto_core_ristretto255_hashbytes());
assert(crypto_core_ristretto255_UNIFORMBYTES >= crypto_core_ristretto255_BYTES); assert(crypto_core_ristretto255_HASHBYTES >= crypto_core_ristretto255_BYTES);
assert(crypto_core_ristretto255_BYTES == crypto_core_ed25519_BYTES); assert(crypto_core_ristretto255_BYTES == crypto_core_ed25519_BYTES);
assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ed25519_SCALARBYTES); assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ed25519_SCALARBYTES);
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ed25519_NONREDUCEDSCALARBYTES); 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"); printf("OK\n");