]> git.codecow.com Git - libnemo.git/commitdiff
Use faster bit shift insead of addition.
authorChris Duncan <chris@zoso.dev>
Sat, 4 Apr 2026 22:11:03 +0000 (15:11 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 4 Apr 2026 22:11:03 +0000 (15:11 -0700)
src/lib/crypto/blake2b.ts

index 03d237e209bb9a689b4dc7a289f1dabff9beaf0b..c43370e489daed14981199865a4744a0470f8ff5 100644 (file)
@@ -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]