Add BigInt64Array and BigUint64Array support to crypto.getRandomValues
Categories
(Core :: DOM: Web Crypto, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox91 | --- | fixed |
People
(Reporter: TimothyGu, Assigned: TimothyGu)
References
Details
Attachments
(1 file)
Given
const b = new BigInt64Array(10);
crypto.getRandomValues(b);
I would expect b to be filled with randomly generated 64-bit integers. However, instead I get
Uncaught DOMException: The type of an object is incompatible with the expected type of the parameter associated to the object
Spec change is pending on https://github.com/w3c/webcrypto/issues/255. WPTs are in bug 1718919.
Comment 1•4 years ago
|
||
I am curious about the motivation to have signed integers here?
| Assignee | ||
Comment 2•4 years ago
|
||
There isn’t a real reason to prevent signed integers from working. BigInt64Array interprets uniformly random bytes as a uniform distribution on [-2^63, 2^63 - 1], which is what people expect. Same with Int8Array, Int16Array, and Int32Array, which are all already supported by crypto.getRandomValues.
What the check was intended to prevent was using Float32Array and Float64Array, since uniformly random bytes do not lead to a uniform distribution for IEEE floating-point numbers. There is no such concern with BigInt64Array or BigUint64Array.
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Comment 5•4 years ago
|
||
| bugherder | ||
Description
•