"version": "0.0.19",
"license": "(GPL-3.0-or-later AND MIT)",
"dependencies": {
+ "blake2b": "^2.1.4",
"blakejs": "^1.2.1"
},
"devDependencies": {
+ "@types/blake2b": "^2.1.3",
"@types/node": "^22.8.6",
"@types/w3c-web-hid": "^1.0.6",
"@types/w3c-web-usb": "^1.0.10",
"license": "Apache-2.0",
"optional": true
},
+ "node_modules/@types/blake2b": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/@types/blake2b/-/blake2b-2.1.3.tgz",
+ "integrity": "sha512-MFCdX0MNxFBP/xEILO5Td0kv6nI7+Q2iRWZbTL/yzH2/eDVZS5Wd1LHdsmXClvsCyzqaZfHFzZaN6BUeUCfSDA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/node": {
"version": "22.8.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.6.tgz",
"dev": true,
"license": "MIT"
},
+ "node_modules/b4a": {
+ "version": "1.6.7",
+ "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz",
+ "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==",
+ "license": "Apache-2.0"
+ },
+ "node_modules/blake2b": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/blake2b/-/blake2b-2.1.4.tgz",
+ "integrity": "sha512-AyBuuJNI64gIvwx13qiICz6H6hpmjvYS5DGkG6jbXMOT8Z3WUJ3V1X0FlhIoT1b/5JtHE3ki+xjtMvu1nn+t9A==",
+ "license": "ISC",
+ "dependencies": {
+ "blake2b-wasm": "^2.4.0",
+ "nanoassert": "^2.0.0"
+ }
+ },
+ "node_modules/blake2b-wasm": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/blake2b-wasm/-/blake2b-wasm-2.4.0.tgz",
+ "integrity": "sha512-S1kwmW2ZhZFFFOghcx73+ZajEfKBqhP82JMssxtLVMxlaPea1p9uoLiUZ5WYyHn0KddwbLc+0vh4wR0KBNoT5w==",
+ "license": "MIT",
+ "dependencies": {
+ "b4a": "^1.0.1",
+ "nanoassert": "^2.0.0"
+ }
+ },
"node_modules/blakejs": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz",
"node": ">=0.8.x"
}
},
+ "node_modules/nanoassert": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-2.0.0.tgz",
+ "integrity": "sha512-7vO7n28+aYO4J+8w96AzhmU8G+Y/xpPDJz/se19ICsqj/momRbb9mh9ZUtkoJ5X3nTnPdhEJyc0qnM6yAsHBaA==",
+ "license": "ISC"
+ },
"node_modules/rxjs": {
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
"test:coverage:report": "npm run test:coverage -- --test-reporter=lcov --test-reporter-destination=coverage.info && genhtml coverage.info --output-directory test/coverage && rm coverage.info && xdg-open test/coverage/index.html"
},
"dependencies": {
+ "blake2b": "^2.1.4",
"blakejs": "^1.2.1"
},
"optionalDependencies": {
"@ledgerhq/hw-transport-webusb": "^6.29.4"
},
"devDependencies": {
+ "@types/blake2b": "^2.1.3",
"@types/node": "^22.8.6",
"@types/w3c-web-hid": "^1.0.6",
"@types/w3c-web-usb": "^1.0.10",
// SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
// SPDX-License-Identifier: GPL-3.0-or-later
+import blake2b from 'blake2b'
import { nanoCKD } from './bip32-key-derivation.js'
-import { bytes, dec } from './convert.js'
-import Tools from './tools.js'
+import { dec, hex } from './convert.js'
if (globalThis.Worker == null) {
const { isMainThread, parentPort } = await import('node:worker_threads')
* @returns {Promise<Account>}
*/
async function ckdBlake2b (seed: string, index: number): Promise<string> {
- const hash = await Tools.blake2b([seed, dec.toHex(index, 8)])
- return bytes.toHex(hash)
+ const input = `${seed}${dec.toHex(index, 8)}`
+ const hash = blake2b(32).update(hex.toBytes(input)).digest('hex')
+ return hash
}