//! SPDX-License-Identifier: GPL-3.0-or-later\r
\r
import { Blake2b } from '#src/lib/blake2b.js'\r
-import { bytes, hex } from '#src/lib/convert.js'\r
+import { hex } from '#src/lib/convert.js'\r
\r
/**\r
* Derives account private keys from a wallet seed using the BLAKE2b hashing\r
*/\r
export class Blake2bCkd {\r
static ckd (seed: ArrayBuffer, index: number): ArrayBuffer {\r
- const indexHex = Math.floor(index).toString(16).padStart(8, '0').toUpperCase()\r
- const inputHex = `${bytes.toHex(new Uint8Array(seed))}${indexHex}`.padStart(72, '0')\r
- const inputBytes = hex.toBytes(inputHex)\r
- const privateKey = new Blake2b(32).update(inputBytes).digest()\r
- return privateKey.buffer\r
+ return new Blake2b(32)\r
+ .update(new Uint8Array(seed))\r
+ .update(hex.toBytes(index.toString(16).padStart(8, '0')))\r
+ .digest()\r
+ .buffer\r
}\r
}\r