}
const update = function (input: Uint8Array) {
- console.log(`this: ${this}`)
- console.dir(this)
if (!(input instanceof Uint8Array))
throw new TypeError(`input must be Uint8Array or Buffer`)
blake2bUpdate(this, input)
* @returns Private child key for the account
*/
async function nanoCKD (seed: string, index: number): Promise<string> {
- console.log(`seed: ${seed}; index: ${index}`)
if (seed.length < 32 || seed.length > 128) {
throw new RangeError(`Invalid seed length`)
}
* Listens for messages from a calling function.
*/
addEventListener('message', (message) => {
- console.log('message received')
const { seed, index, blake2b } = message.data ?? message
ckdBlake2b(seed, index, blake2b).then(key => postMessage({ index, key }))
})
*/
async function ckdBlake2b (seed: string, index: number, b2b: any): Promise<string> {
const blake2b = Function(`return ${b2b}`)()
- console.log(blake2b)
const indexHex = index.toString(16).padStart(8, '0').toUpperCase()
const inputHex = `${seed}${indexHex}`.padStart(72, '0')
const inputArray = (inputHex.match(/.{1,2}/g) ?? []).map(h => parseInt(h, 16))