@@ -12,7 +12,6 @@ import (
12
12
_ "crypto/sha256"
13
13
// adds sha512 capability to crypto.SHA512
14
14
_ "crypto/sha512"
15
-
16
15
// adds ripemd160 capability to crypto.RIPEMD160
17
16
_ "golang.org/x/crypto/ripemd160" //nolint:staticcheck
18
17
)
@@ -164,15 +163,24 @@ func doHash(hashOp HashOp, preimage []byte) ([]byte, error) {
164
163
case HashOp_BITCOIN :
165
164
// ripemd160(sha256(x))
166
165
sha := crypto .SHA256 .New ()
167
- sha .Write (preimage )
166
+ _ , err := sha .Write (preimage )
167
+ if err != nil {
168
+ return nil , err
169
+ }
168
170
tmp := sha .Sum (nil )
169
- hash := crypto .RIPEMD160 .New ()
170
- hash .Write (tmp )
171
- return hash .Sum (nil ), nil
171
+ bitcoinHash := crypto .RIPEMD160 .New ()
172
+ _ , err = bitcoinHash .Write (tmp )
173
+ if err != nil {
174
+ return nil , err
175
+ }
176
+ return bitcoinHash .Sum (nil ), nil
172
177
case HashOp_SHA512_256 :
173
- hash := crypto .SHA512_256 .New ()
174
- hash .Write (preimage )
175
- return hash .Sum (nil ), nil
178
+ shaHash := crypto .SHA512_256 .New ()
179
+ _ , err := shaHash .Write (preimage )
180
+ if err != nil {
181
+ return nil , err
182
+ }
183
+ return shaHash .Sum (nil ), nil
176
184
}
177
185
return nil , fmt .Errorf ("unsupported hashop: %d" , hashOp )
178
186
}
@@ -183,7 +191,10 @@ type hasher interface {
183
191
184
192
func hashBz (h hasher , preimage []byte ) ([]byte , error ) {
185
193
hh := h .New ()
186
- hh .Write (preimage )
194
+ _ , err := hh .Write (preimage )
195
+ if err != nil {
196
+ return nil , err
197
+ }
187
198
return hh .Sum (nil ), nil
188
199
}
189
200
@@ -193,8 +204,8 @@ func prepareLeafData(hashOp HashOp, lengthOp LengthOp, data []byte) ([]byte, err
193
204
if err != nil {
194
205
return nil , err
195
206
}
196
- ldata , err := doLengthOp ( lengthOp , hdata )
197
- return ldata , err
207
+
208
+ return doLengthOp ( lengthOp , hdata )
198
209
}
199
210
200
211
func validateSpec (spec * ProofSpec ) bool {
0 commit comments