xmr-btc-swap/monero-adaptor/depend/hash/hash.c

22 lines
496 B
C
Raw Normal View History

2021-04-18 21:00:07 -04:00
#include <stdint.h>
2021-04-20 01:01:34 -04:00
#include "include/keccak.h"
#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);
}
// 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) {
uint8_t md[32];
ge_p2 hash_p2;
2021-04-20 02:34:44 -04:00
ge_p1p1 hash8_p1p1;
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);
ge_mul8(&hash8_p1p1, &hash_p2);
ge_p1p1_to_p3(hash8_p3, &hash8_p1p1);
}