On 15/03/2019 07:13, Jaime Hablutzel via dev-security-policy wrote:
64bits_entropy = GetRandom64Bits() //This returns 64 random bits from a
CSPRNG with at least one bit in the highest byte set to 1

is, strictly speaking, not true. The best possible implementation for
GetRandom64Bits(), as described, only returns 63.994353 bits of entropy,
not 64.


Can you share how did you get the previous 63.994353?.

I'm trying the following and I'm getting a different value:

a = 2^64 = 18446744073709551616
b = 0x80000000000000 = 36028797018963968

(a - b) / a * 64 = 63.875

Maybe I'm misunderstanding something.

Entropy in bits is measured as the log2 of the possible values. So:

>>> math.log2(2**64)
64.0

Of 64-bit numbers, 255/256 have at least one bit set in the highest byte (only those starting with 00 don't), so:

>>> math.log2(2**64 * 255/256)
63.99435343685886

--
Hector Martin "marcan"
Public key: https://mrcn.st/pub
_______________________________________________
dev-security-policy mailing list
dev-security-policy@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-security-policy

Reply via email to