chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+3
View File
@@ -0,0 +1,3 @@
import type { ScryptParams } from './types.js';
export declare const ALLOWED_PARAMS: ScryptParams[];
export declare const DEFAULT_PARAMS: ScryptParams;
+13
View File
@@ -0,0 +1,13 @@
export const ALLOWED_PARAMS = [
{ N: 1 << 13, p: 10, r: 8 },
{ N: 1 << 14, p: 5, r: 8 },
{ N: 1 << 15, p: 3, r: 8 },
{ N: 1 << 15, p: 1, r: 8 },
{ N: 1 << 16, p: 2, r: 8 },
{ N: 1 << 17, p: 1, r: 8 }
];
export const DEFAULT_PARAMS = {
N: 1 << 17,
p: 1,
r: 8
};
+8
View File
@@ -0,0 +1,8 @@
import type { ScryptParams } from './types.js';
interface Result {
params: ScryptParams;
password: Uint8Array;
salt: Uint8Array;
}
export declare function scryptEncode(passphrase?: string | Uint8Array, salt?: Uint8Array, params?: ScryptParams, onlyJs?: boolean): Result;
export {};
+15
View File
@@ -0,0 +1,15 @@
import { scrypt as scryptJs } from '@noble/hashes/scrypt';
import { hasBigInt, objectSpread, u8aToU8a } from '@pezkuwi/util';
import { isReady, scrypt } from '@pezkuwi/wasm-crypto';
import { randomAsU8a } from '../random/asU8a.js';
import { DEFAULT_PARAMS } from './defaults.js';
export function scryptEncode(passphrase, salt = randomAsU8a(), params = DEFAULT_PARAMS, onlyJs) {
const u8a = u8aToU8a(passphrase);
return {
params,
password: !hasBigInt || (!onlyJs && isReady())
? scrypt(u8a, salt, Math.log2(params.N), params.r, params.p)
: scryptJs(u8a, salt, objectSpread({ dkLen: 64 }, params)),
salt
};
}
+7
View File
@@ -0,0 +1,7 @@
import type { ScryptParams } from './types.js';
interface Result {
params: ScryptParams;
salt: Uint8Array;
}
export declare function scryptFromU8a(data: Uint8Array): Result;
export {};
+24
View File
@@ -0,0 +1,24 @@
import { u8aToBn } from '@pezkuwi/util';
import { BN_LE_OPTS } from '../bn.js';
import { ALLOWED_PARAMS } from './defaults.js';
export function scryptFromU8a(data) {
if (!(data instanceof Uint8Array)) {
throw new Error('Expected input to be a Uint8Array');
}
// Ensure the input is exactly 44 bytes: 32 for salt + 3 * 4 for N, p, r
if (data.length < 32 + 12) {
throw new Error(`Invalid input length: expected 44 bytes, found ${data.length}`);
}
const salt = data.subarray(0, 32);
const N = u8aToBn(data.subarray(32, 36), BN_LE_OPTS).toNumber();
const p = u8aToBn(data.subarray(36, 40), BN_LE_OPTS).toNumber();
const r = u8aToBn(data.subarray(40, 44), BN_LE_OPTS).toNumber();
if (N > (1 << 20) || p > 4 || r > 16) {
throw new Error('Scrypt parameters exceed safe limits');
}
const isAllowed = ALLOWED_PARAMS.some((preset) => preset.N === N && preset.p === p && preset.r === r);
if (!isAllowed) {
throw new Error('Invalid injected scrypt params found');
}
return { params: { N, p, r }, salt };
}
+3
View File
@@ -0,0 +1,3 @@
export { scryptEncode } from './encode.js';
export { scryptFromU8a } from './fromU8a.js';
export { scryptToU8a } from './toU8a.js';
+3
View File
@@ -0,0 +1,3 @@
export { scryptEncode } from './encode.js';
export { scryptFromU8a } from './fromU8a.js';
export { scryptToU8a } from './toU8a.js';
+2
View File
@@ -0,0 +1,2 @@
import type { ScryptParams } from './types.js';
export declare function scryptToU8a(salt: Uint8Array, { N, p, r }: ScryptParams): Uint8Array;
+5
View File
@@ -0,0 +1,5 @@
import { bnToU8a, u8aConcat } from '@pezkuwi/util';
import { BN_LE_32_OPTS } from '../bn.js';
export function scryptToU8a(salt, { N, p, r }) {
return u8aConcat(salt, bnToU8a(N, BN_LE_32_OPTS), bnToU8a(p, BN_LE_32_OPTS), bnToU8a(r, BN_LE_32_OPTS));
}
+6
View File
@@ -0,0 +1,6 @@
/** The params that control scrypt generation */
export interface ScryptParams {
N: number;
p: number;
r: number;
}
+1
View File
@@ -0,0 +1 @@
export {};