fix: implement scrypt using @noble/hashes/scrypt

- Fixed scrypt function that was throwing 'not yet implemented' error
- Uses @noble/hashes/scrypt for proper scrypt KDF
- Fixes account creation/import in pezkuwi-extension
- Version bump to 7.5.18
This commit is contained in:
2026-02-02 04:47:21 +03:00
parent 6039925ed1
commit 12a26227eb
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
],
"type": "module",
"types": "./build/index.d.ts",
"version": "7.5.15",
"version": "7.5.18",
"main": "./build/cjs/index.js",
"module": "./build/index.js",
"exports": {
+6 -3
View File
@@ -317,6 +317,7 @@ import { pbkdf2 as noblePbkdf2 } from '@noble/hashes/pbkdf2';
import { blake2b as nobleBlake2b } from '@noble/hashes/blake2b';
import { hmac } from '@noble/hashes/hmac';
import { keccak_256, keccak_512 } from '@noble/hashes/sha3';
import { scrypt as nobleScrypt } from '@noble/hashes/scrypt';
function normalizeString(str: string): string {
return (str || '').normalize('NFKD');
@@ -483,9 +484,11 @@ export function pbkdf2(data: Uint8Array, salt: Uint8Array, rounds: number): Uint
return noblePbkdf2(nobleSha512, data, salt, { c: rounds, dkLen: 64 });
}
export function scrypt(_password: Uint8Array, _salt: Uint8Array, _log2n: number, _r: number, _p: number): Uint8Array {
// scrypt is rarely used - defer to @noble/hashes/scrypt if needed
throw new Error('scrypt not yet implemented - use @pezkuwi/util-crypto scryptSync instead');
export function scrypt(password: Uint8Array, salt: Uint8Array, log2n: number, r: number, p: number): Uint8Array {
// Convert log2n to N (cost parameter)
// log2n is log2(N), so N = 2^log2n
const N = 1 << log2n;
return nobleScrypt(password, salt, { N, r, p, dkLen: 64 });
}
export function sha256(data: Uint8Array): Uint8Array {
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @pezkuwi/dev
export const packageInfo = { name: '@pezkuwi/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.15' };
export const packageInfo = { name: '@pezkuwi/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.18' };