Closed Bug 1718932 Opened 4 years ago Closed 4 years ago

Add BigInt64Array and BigUint64Array support to crypto.getRandomValues

Categories

(Core :: DOM: Web Crypto, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
91 Branch
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.

I am curious about the motivation to have signed integers here?

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: nobody → timothygu99
Status: NEW → ASSIGNED
Attachment #9229627 - Attachment description: Bug 1718932 - Support Big(U)Int64Array in crypto.getRandomValues. r=beurdouche → Bug 1718932 - Support Big(U)Int64Array in crypto.getRandomValues. r=keeler
Blocks: 1718919
Pushed by dkeeler@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/23e2efb39391 Support Big(U)Int64Array in crypto.getRandomValues. r=keeler
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Regressions: 1719799
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: