forked from lthn/blockchain
crypto: ge_bytes_hash_to_ec() added
This commit is contained in:
parent
a98317cd52
commit
46d9895801
3 changed files with 27 additions and 6 deletions
|
|
@ -30,6 +30,7 @@
|
|||
#include <stddef.h>
|
||||
#include "warnings.h"
|
||||
#include "crypto-ops.h"
|
||||
#include "hash-ops.h" // for cn_fast_hash
|
||||
|
||||
DISABLE_VS_WARNINGS(4146 4244)
|
||||
|
||||
|
|
@ -3724,3 +3725,18 @@ void sc_invert(unsigned char* out, const unsigned char* z)
|
|||
sc_mul(out, out, out);
|
||||
sc_mul(out, out, z);
|
||||
}
|
||||
|
||||
// res = Hp(ge_bytes)
|
||||
// where Hp = 8 * ge_fromfe_frombytes_vartime(cn_fast_hash(ge_bytes))
|
||||
// In: ge_bytes -- points to 32 bytes data
|
||||
void ge_bytes_hash_to_ec(ge_p3 *res, const unsigned char *ge_bytes)
|
||||
{
|
||||
unsigned char h[HASH_SIZE];
|
||||
ge_p2 point;
|
||||
ge_p1p1 point2;
|
||||
|
||||
cn_fast_hash(ge_bytes, 32, h);
|
||||
ge_fromfe_frombytes_vartime(&point, &h[0]);
|
||||
ge_mul8(&point2, &point);
|
||||
ge_p1p1_to_p3(res, &point2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ void ge_scalarmult_p3(ge_p3 *, const unsigned char *, const ge_p3 *);
|
|||
void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp);
|
||||
void ge_mul8(ge_p1p1 *, const ge_p2 *);
|
||||
void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *);
|
||||
void ge_bytes_hash_to_ec(ge_p3 *, const unsigned char *);
|
||||
|
||||
void ge_p3_0(ge_p3 *h);
|
||||
void ge_sub(ge_p1p1 *, const ge_p3 *, const ge_cached *);
|
||||
|
||||
|
|
|
|||
|
|
@ -303,11 +303,13 @@ namespace crypto {
|
|||
|
||||
PUSH_VS_WARNINGS
|
||||
DISABLE_VS_WARNINGS(4200)
|
||||
struct rs_comm_entry
|
||||
{
|
||||
ec_point a, b;
|
||||
};
|
||||
struct rs_comm {
|
||||
struct rs_comm_entry
|
||||
{
|
||||
ec_point a, b;
|
||||
};
|
||||
|
||||
struct rs_comm
|
||||
{
|
||||
hash h;
|
||||
struct rs_comm_entry ab[];
|
||||
};
|
||||
|
|
@ -422,4 +424,5 @@ POP_VS_WARNINGS
|
|||
sc_sub(&h, &h, &sum);
|
||||
return sc_isnonzero(&h) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue