From: Chris Duncan Date: Sat, 4 Apr 2026 22:11:03 +0000 (-0700) Subject: Use faster bit shift insead of addition. X-Git-Tag: v0.11.0~1 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=26c46c8d3d9262c7166549d284463144e7fe4c5e;p=libnemo.git Use faster bit shift insead of addition. --- diff --git a/src/lib/crypto/blake2b.ts b/src/lib/crypto/blake2b.ts index 03d237e..c43370e 100644 --- a/src/lib/crypto/blake2b.ts +++ b/src/lib/crypto/blake2b.ts @@ -77,13 +77,13 @@ export class Blake2b { } #G (r: number, i: number, a: number, b: number, c: number, d: number): void { - this.#v[a] += this.#v[b] + this.#m[(this.constructor as typeof Blake2b).SIGMA[r][i + i]] + this.#v[a] += this.#v[b] + this.#m[(this.constructor as typeof Blake2b).SIGMA[r][i << 1]] this.#v[d] ^= this.#v[a] this.#v[d] = (this.#v[d] >> 32n) | (this.#v[d] << 32n) this.#v[c] += this.#v[d] this.#v[b] ^= this.#v[c] this.#v[b] = (this.#v[b] >> 24n) | (this.#v[b] << 40n) - this.#v[a] += this.#v[b] + this.#m[(this.constructor as typeof Blake2b).SIGMA[r][i + i + 1]] + this.#v[a] += this.#v[b] + this.#m[(this.constructor as typeof Blake2b).SIGMA[r][(i << 1) + 1]] this.#v[d] ^= this.#v[a] this.#v[d] = (this.#v[d] >> 16n) | (this.#v[d] << 48n) this.#v[c] += this.#v[d]