2021-04-18 21:00:07 -04:00
|
|
|
#include <stdint.h>
|
2021-04-20 01:01:34 -04:00
|
|
|
#include "include/keccak.h"
|
2021-04-19 19:36:31 -04:00
|
|
|
#include "include/crypto-ops.h"
|
2021-04-18 21:00:07 -04:00
|
|
|
|
2021-04-20 01:01:34 -04:00
|
|
|
void hash_to_scalar(const uint8_t *in, uint8_t *md) {
|
|
|
|
keccak(in, 32, md, 32);
|
2021-04-19 01:51:10 -04:00
|
|
|
sc_reduce32(md);
|
|
|
|
}
|
|
|
|
|
2021-04-19 08:04:18 -04:00
|
|
|
// Hash a key to p3 representation
|
2021-04-20 01:01:34 -04:00
|
|
|
void hash_to_p3(const uint8_t *in, ge_p3 *hash8_p3) {
|
2021-04-19 08:04:18 -04:00
|
|
|
uint8_t md[32];
|
|
|
|
ge_p2 hash_p2;
|
2021-04-20 02:34:44 -04:00
|
|
|
ge_p1p1 hash8_p1p1;
|
2021-04-19 08:04:18 -04:00
|
|
|
|
2021-04-20 02:34:44 -04:00
|
|
|
keccak(in, 32, md, 32);
|
2021-04-20 01:01:34 -04:00
|
|
|
ge_fromfe_frombytes_vartime(&hash_p2, md);
|
2021-04-19 08:04:18 -04:00
|
|
|
ge_mul8(&hash8_p1p1, &hash_p2);
|
|
|
|
ge_p1p1_to_p3(hash8_p3, &hash8_p1p1);
|
|
|
|
}
|
|
|
|
|