mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-21 23:58:09 +00:00
Stop using numeric_limits for the constant "255", and fix a bug.
The bug is that `x % 255` is not quite the same thing as `x % 256`; but `x & 255` is. The stylistic issue is that `numeric_limits<uint8_t>::max()` is a very verbose way of spelling `255`.
This commit is contained in:
parent
f8b883dcd4
commit
9504d804e0
@ -45,7 +45,7 @@ bc::ec_secret random_secret(std::default_random_engine& engine)
|
||||
bc::ec_secret secret;
|
||||
// Iterate through every byte setting a random value...
|
||||
for (uint8_t& byte: secret)
|
||||
byte = engine() % std::numeric_limits<uint8_t>::max();
|
||||
byte = engine() & 255;
|
||||
// Return result.
|
||||
return secret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user