Skip to content

Commit 48996e1

Browse files
committed
fix mixing function
1 parent fef8423 commit 48996e1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/blake3-wasm/assembly/blake3.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,13 @@ const MSG_PERMUTATION: StaticArray<i32> = [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12,
2121
// The mixing function, G, which mixes either a column or a diagonal.
2222
function g(state: StaticArray<u32>, a: i32, b: i32, c: i32, d: i32, mx: u32, my: u32): void {
2323
state[a] = state[a] + state[b] + mx;
24-
state[d] = rotl32(state[d] ^ state[a], 16);
24+
state[d] = rotr(state[d] ^ state[a], 16);
2525
state[c] = state[c] + state[d];
26-
state[b] = rotl32(state[b] ^ state[c], 12);
26+
state[b] = rotr(state[b] ^ state[c], 12);
2727
state[a] = state[a] + state[b] + my;
28-
state[d] = rotl32(state[d] ^ state[a], 8);
28+
state[d] = rotr(state[d] ^ state[a], 8);
2929
state[c] = state[c] + state[d];
30-
state[b] = rotl32(state[b] ^ state[c], 7);
31-
}
32-
33-
// Rotate left by n bits
34-
function rotl32(x: u32, n: u32): u32 {
35-
return (x << n) | (x >>> (32 - n));
30+
state[b] = rotr(state[b] ^ state[c], 7);
3631
}
3732

3833
function round(state: StaticArray<u32>, m: StaticArray<u32>): void {

0 commit comments

Comments
 (0)