}
static #hash (seed: bigint, hash: string): bigint {
- if (this.#debug) console.log(`hash: ${hash}`)
// Reset buffers before each calculation
for (let i = 0; i < 8; i++) {
this.#v[i] = this.#blake2b_IV[i]
// Set up input buffers
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.#mView.setBigUint64(i / 2 + 8, BigInt(`0x${u64}`))
}
- if (this.#debug) console.log('m', this.#m)
for (let r = 0; r < 12; r++) {
const s = this.#blake2b_sigma[r]
const random1 = Math.floor(Math.random() * 0xffffffff)
nonce = (BigInt(random0) << 32n) | BigInt(random1)
result = this.#hash(nonce, hash)
- if (attempts % 1000000n === 0n) console.log(`${attempts} attempts`)
} while (result < threshold)
console.log(performance.now() - start)
this.#busy = false