2 #include "crypto/sha256.h"
4 uint256 PRF(bool a, bool b, bool c, bool d,
9 unsigned char blob[64];
11 memcpy(&blob[0], x.begin(), 32);
12 memcpy(&blob[32], y.begin(), 32);
15 blob[0] |= (a ? 1 << 7 : 0) | (b ? 1 << 6 : 0) | (c ? 1 << 5 : 0) | (d ? 1 << 4 : 0);
18 hasher.Write(blob, 64);
19 hasher.FinalizeNoPadding(res.begin());
24 uint256 PRF_addr(const uint252& a_sk, unsigned char t)
29 return PRF(1, 1, 0, 0, a_sk, y);
32 uint256 PRF_addr_a_pk(const uint252& a_sk)
34 return PRF_addr(a_sk, 0);
37 uint256 PRF_addr_sk_enc(const uint252& a_sk)
39 return PRF_addr(a_sk, 1);
42 uint256 PRF_nf(const uint252& a_sk, const uint256& rho)
44 return PRF(1, 1, 1, 0, a_sk, rho);
47 uint256 PRF_pk(const uint252& a_sk, size_t i0, const uint256& h_sig)
49 if ((i0 != 0) && (i0 != 1)) {
50 throw std::domain_error("PRF_pk invoked with index out of bounds");
53 return PRF(0, i0, 0, 0, a_sk, h_sig);
56 uint256 PRF_rho(const uint252& phi, size_t i0, const uint256& h_sig)
58 if ((i0 != 0) && (i0 != 1)) {
59 throw std::domain_error("PRF_rho invoked with index out of bounds");
62 return PRF(0, i0, 1, 0, phi, h_sig);