static #blake2b_sigma: number[][]
static #v: BigUint64Array
static #m: BigUint64Array
+ static #mView: DataView
static async init (): Promise<void> {
if (this.#busy) return
]
this.#v = new BigUint64Array(16)
this.#m = new BigUint64Array(16)
+ this.#mView = new DataView(this.#m.buffer)
console.log(`NanoPow CPU initialized.`)
} catch (err) {
throw new Error('NanoPow CPU initialization failed.', { cause: err })
this.#v[12] ^= 40n // Output length
// Set up input buffers
- this.#m[0] = seed
- if (this.#debug) console.log(`seed: ${this.#m[0].toString(16).padStart(16, '0')}`)
+ this.#mView.setBigUint64(0, seed, true)
+ if (this.#debug) console.log(`seed: ${this.#m[0].toString(16).padStart(16, '0')} (${this.#m[0]})`)
for (let i = 0; i < hash.length; i += 16) {
const u64 = hash.slice(i, i + 16)
- this.#m[i / 16 + 1] = BigInt(`0x${u64}`)
+ this.#mView.setBigUint64(i / 2 + 8, BigInt(`0x${u64}`))
}
if (this.#debug) console.log('m', this.#m)