Skip to content

Commit b406ad1

Browse files
committed
go fix
1 parent 471152a commit b406ad1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

crypto/blobs/testdata.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
_ "embed"
55
"fmt"
66
"math/big"
7+
"strings"
78

89
"github.com/consensys/gnark/frontend"
910
"github.com/consensys/gnark/std"
@@ -205,17 +206,17 @@ func hexStrToBlob(hexStr string) (*types.Blob, error) {
205206
// hexStrToBytes converts a hex string to bytes
206207
func hexStrToBytes(hexStr string) ([]byte, error) {
207208
// Remove any whitespace/newlines
208-
cleaned := ""
209+
var cleaned strings.Builder
209210
for _, c := range hexStr {
210211
if (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') {
211-
cleaned += string(c)
212+
cleaned.WriteString(string(c))
212213
}
213214
}
214215

215-
result := make([]byte, len(cleaned)/2)
216+
result := make([]byte, len(cleaned.String())/2)
216217
for i := range result {
217-
high := hexCharToNibble(cleaned[i*2])
218-
low := hexCharToNibble(cleaned[i*2+1])
218+
high := hexCharToNibble(cleaned.String()[i*2])
219+
low := hexCharToNibble(cleaned.String()[i*2+1])
219220
result[i] = (high << 4) | low
220221
}
221222
return result, nil

0 commit comments

Comments
 (0)