Scrypt password-based key derivation function (RFC 7914)
Ƭ TypedArray: Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array
▸ salsa208Core(arr
): void
Salsa20/8 Core is a round-reduced variant of the Salsa20 Core. It is a hash function from 64-octet strings to 64-octet strings. Note that Salsa20/8 Core is not a cryptographic hash function since it is not collision resistant.
This function modifies the ArrayBuffer of the input UInt32Array
Name | Type | Description |
---|---|---|
arr |
Uint32Array |
a binary array of 64 octets |
void
▸ salt(length?
): ArrayBuffer
Returns an ArrayBuffer of the desired length in bytes filled with cryptographically secure random bytes
Throws
length must be integer >= 0
Name | Type | Default value | Description |
---|---|---|---|
length? |
number |
16 |
The length in bytes of the random salt |
ArrayBuffer
▸ scrypt(P
, S
, dkLen
, scryptParams?
): Promise
<ArrayBuffer
>
The scrypt Algorithm (RFC 7914)
Name | Type | Description |
---|---|---|
P |
string | TypedArray | ArrayBuffer | DataView |
A unicode string with a passphrase. |
S |
string | TypedArray | ArrayBuffer | DataView |
A salt. This should be a random or pseudo-random value of at least 16 bytes. You can easily get one with crypto.getRandomValues(new Uint8Array(16)) in browser's JS or with crypto.randomBytes(16).buffer in Node.js |
dkLen |
number |
Intended output length in octets of the derived key; a positive integer less than or equal to (2^32 - 1) * hLen where hLen is 32. |
scryptParams? |
ScryptParams |
scrypt configuration parameters: N, p, r |
Promise
<ArrayBuffer
>
- a derived key of dKLen bytes
▸ scryptBlockMix(B
): void
The scryptBlockMix algorithm is the same as the BlockMix algorithm described in the original scrypt paper but with Salsa20/8 Core used as the hash function.
This function modifies the ArrayBuffer of the input BigUint64Array
Name | Type | Description |
---|---|---|
B |
Uint32Array |
B[0] || B[1] || ... || B[2 * r - 1] Input octet string (of size 128 * r octets), treated as 2 * r 64-octet blocks, where each element in B is a 64-octet block. |
void
▸ scryptROMix(B
, N
): void
The scryptROMix algorithm
This function modifies the ArrayBuffer of the input array
Name | Type | Description |
---|---|---|
B |
Uint32Array |
Input octet vector of length 128 * r octets. |
N |
number |
CPU/Memory cost parameter, must be larger than 1, a power of 2, and less than 2^(128 * r / 8). |
void