@@ -54,7 +54,12 @@ func (h *Hasher) hashLeavesBatch(start, end, bw, secsize, prefixLen int) {
5454 for j := batch ; j < 8 ; j ++ {
5555 inputs [j ] = nil
5656 }
57- outputs := keccak .Sum256x8 (inputs )
57+ var outputs [8 ]keccak.Hash256
58+ if h .useSIMD {
59+ outputs = keccak .Sum256x8 (inputs )
60+ } else {
61+ outputs = keccak .Sum256x8Scalar (inputs )
62+ }
5863 for j := 0 ; j < batch ; j ++ {
5964 leaf := h .bmt .levels [0 ][i + j ]
6065 if leaf .isLeft {
@@ -83,7 +88,12 @@ func (h *Hasher) hashLeavesBatch(start, end, bw, secsize, prefixLen int) {
8388 for j := batch ; j < 4 ; j ++ {
8489 inputs [j ] = nil
8590 }
86- outputs := keccak .Sum256x4 (inputs )
91+ var outputs [4 ]keccak.Hash256
92+ if h .useSIMD {
93+ outputs = keccak .Sum256x4 (inputs )
94+ } else {
95+ outputs = keccak .Sum256x4Scalar (inputs )
96+ }
8797 for j := 0 ; j < batch ; j ++ {
8898 leaf := h .bmt .levels [0 ][i + j ]
8999 if leaf .isLeft {
@@ -119,7 +129,12 @@ func (h *Hasher) hashNodesBatch(nodes []*node, bw, prefixLen int) {
119129 for j := batch ; j < 8 ; j ++ {
120130 inputs [j ] = nil
121131 }
122- outputs := keccak .Sum256x8 (inputs )
132+ var outputs [8 ]keccak.Hash256
133+ if h .useSIMD {
134+ outputs = keccak .Sum256x8 (inputs )
135+ } else {
136+ outputs = keccak .Sum256x8Scalar (inputs )
137+ }
123138 for j := 0 ; j < batch ; j ++ {
124139 n := nodes [i + j ]
125140 if n .isLeft {
@@ -145,7 +160,12 @@ func (h *Hasher) hashNodesBatch(nodes []*node, bw, prefixLen int) {
145160 for j := batch ; j < 4 ; j ++ {
146161 inputs [j ] = nil
147162 }
148- outputs := keccak .Sum256x4 (inputs )
163+ var outputs [4 ]keccak.Hash256
164+ if h .useSIMD {
165+ outputs = keccak .Sum256x4 (inputs )
166+ } else {
167+ outputs = keccak .Sum256x4Scalar (inputs )
168+ }
149169 for j := 0 ; j < batch ; j ++ {
150170 n := nodes [i + j ]
151171 if n .isLeft {
0 commit comments