From 3006cea8da0ba2a6c4b2ffb6cd6ed0b0d538ff74 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 3 Mar 2025 08:04:59 -0800 Subject: [PATCH] Fix missing compression step when resetting v. Start adding some logging for benchmarking. --- src/classes/cpu.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/classes/cpu.ts b/src/classes/cpu.ts index 44fea21..55e6d24 100644 --- a/src/classes/cpu.ts +++ b/src/classes/cpu.ts @@ -103,7 +103,6 @@ export class NanoPowCpu { v[c] += v[d] v[b] ^= v[c] v[b] = (v[b] >> 24n) | (v[b] << 40n) - v[a] += v[b] v[a] += m[y] v[d] ^= v[a] @@ -124,6 +123,7 @@ export class NanoPowCpu { } this.#v[0] ^= 0x01010008n // depth = 1; fanout = 1; outlen = 8 this.#v[12] ^= 40n // Output length + this.#v[14] = ~this.#v[14] // Compression // Set up input buffers this.#mView.setBigUint64(0, seed, true) @@ -171,19 +171,19 @@ export class NanoPowCpu { : BigInt(`0x${options.threshold}00000000`) this.#debug = !!(options?.debug) - // let attempts = 0n + let attempts = 0n let result = 0n let nonce = 0n - // let start = performance.now() + let start = performance.now() do { - // attempts++ + attempts++ const random0 = Math.floor(Math.random() * 0xffffffff) const random1 = Math.floor(Math.random() * 0xffffffff) nonce = (BigInt(random0) << 32n) | BigInt(random1) - // if (this.#debug) console.log(`seed: ${seed.toString(16).padStart(16, '0')}`) result = this.#hash(nonce, hash) - // if (this.#debug) console.log(performance.now() - start) + if (attempts % 1000000n === 0n) console.log(`${attempts} attempts`) } while (result < threshold) + console.log(performance.now() - start) this.#busy = false return result.toString(16).padStart(16, '0') } -- 2.34.1