1
0
Fork 0
forked from lthn/blockchain

crypto: ge_bytes_hash_to_ec_32

This commit is contained in:
sowle 2021-04-10 23:43:54 +03:00
parent 670bacbf3f
commit 457b84fd7b
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 12 additions and 6 deletions

View file

@ -4323,23 +4323,28 @@ void ge_p2_to_p3(ge_p3 *r, const ge_p2 *t)
/*
In: ge_bytes -- points to 32 bytes of data
Out: res = Hp(ge_bytes)
where Hp = 8 * ge_fromfe_frombytes_vartime(cn_fast_hash(ge_bytes))
In: data -- points to 'size' bytes of data
Out: res = Hp(data)
where Hp = 8 * ge_fromfe_frombytes_vartime(cn_fast_hash(data))
*/
void ge_bytes_hash_to_ec(ge_p3 *res, const unsigned char *ge_bytes)
void ge_bytes_hash_to_ec(ge_p3 *res, const void *data, size_t size)
{
unsigned char h[HASH_SIZE];
ge_p2 point;
ge_p1p1 point2;
cn_fast_hash(ge_bytes, 32, (char*)h);
cn_fast_hash(data, size, (char*)h);
ge_fromfe_frombytes_vartime(&point, &h[0]);
/*ge_p2_to_p3(res, &point); -- can be used to avoid multiplication by 8 for debugging */
ge_mul8(&point2, &point);
ge_p1p1_to_p3(res, &point2);
}
void ge_bytes_hash_to_ec_32(ge_p3 *res, const unsigned char *ge_bytes)
{
ge_bytes_hash_to_ec(res, ge_bytes, 32);
}
void ge_mul8_p3(ge_p3 *r, const ge_p3 *t)
{
ge_p1p1 p1;

View file

@ -107,7 +107,8 @@ void ge_mul8(ge_p1p1 *, const ge_p2 *);
void ge_mul8_p3(ge_p3 *, const ge_p3 *);
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *);
void ge_p2_to_p3(ge_p3 *r, const ge_p2 *t);
void ge_bytes_hash_to_ec(ge_p3 *, const unsigned char *);
void ge_bytes_hash_to_ec(ge_p3 *, const void *, size_t);
void ge_bytes_hash_to_ec_32(ge_p3 *, const unsigned char *);
void ge_p3_0(ge_p3 *h);
void ge_sub(ge_p1p1 *, const ge_p3 *, const ge_cached *);