aboutsummaryrefslogtreecommitdiff
path: root/src/ringct
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-07-27 14:23:54 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-07-27 14:23:54 -0500
commit3fde902394946281665531abd742c64bdb23be25 (patch)
tree9eab237d53c8cda2c1d5217880b135c02f6f0b61 /src/ringct
parentMerge pull request #4091 (diff)
parentcrypto: remove slight bias in key generation due to modulo (diff)
downloadmonero-3fde902394946281665531abd742c64bdb23be25.tar.xz
Merge pull request #4097
61caab8 crypto: remove slight bias in key generation due to modulo (moneromooo-monero)
Diffstat (limited to 'src/ringct')
-rw-r--r--src/ringct/rctOps.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ringct/rctOps.cpp b/src/ringct/rctOps.cpp
index 68cc43128..50693bad7 100644
--- a/src/ringct/rctOps.cpp
+++ b/src/ringct/rctOps.cpp
@@ -62,14 +62,13 @@ namespace rct {
//generates a random scalar which can be used as a secret key or mask
void skGen(key &sk) {
- sk = crypto::rand<key>();
- sc_reduce32(sk.bytes);
+ random32_unbiased(sk.bytes);
}
//generates a random scalar which can be used as a secret key or mask
key skGen() {
- key sk = crypto::rand<key>();
- sc_reduce32(sk.bytes);
+ key sk;
+ skGen(sk);
return sk;
}
@@ -79,9 +78,8 @@ namespace rct {
CHECK_AND_ASSERT_THROW_MES(rows > 0, "0 keys requested");
keyV rv(rows);
size_t i = 0;
- crypto::rand(rows * sizeof(key), (uint8_t*)&rv[0]);
for (i = 0 ; i < rows ; i++) {
- sc_reduce32(rv[i].bytes);
+ skGen(rv[i]);
}
return rv;
}