Enforce first four bits are zero for all spending keys and phi.

This commit is contained in:
Sean Bowe
2016-05-16 09:50:31 -06:00
parent 4ac1841614
commit defe37a6d4
15 changed files with 123 additions and 42 deletions

View File

@@ -136,7 +136,7 @@ typename NoteDecryption<MLEN>::Plaintext NoteDecryption<MLEN>::decrypt
}
template<size_t MLEN>
uint256 NoteEncryption<MLEN>::generate_privkey(const uint256 &a_sk)
uint256 NoteEncryption<MLEN>::generate_privkey(const uint252 &a_sk)
{
uint256 sk = PRF_addr_sk_enc(a_sk);
@@ -165,6 +165,14 @@ uint256 random_uint256()
return ret;
}
uint252 random_uint252()
{
uint256 rand = random_uint256();
(*rand.begin()) &= 0x0F;
return uint252(rand);
}
template class NoteEncryption<ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE>;
template class NoteDecryption<ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE>;