Skip to content

Commit 1fe759c

Browse files
committed
switch blake3 -> sha256
1 parent ecfbcac commit 1fe759c

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ require (
6262
github.com/supranational/blst v0.3.14
6363
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
6464
github.com/urfave/cli/v2 v2.27.5
65-
github.com/zeebo/blake3 v0.2.4
6665
go.uber.org/automaxprocs v1.5.2
6766
go.uber.org/goleak v1.3.0
6867
golang.org/x/crypto v0.36.0

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,6 @@ github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBi
365365
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
366366
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
367367
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
368-
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
369-
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
370-
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
371-
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
372-
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
373-
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
374368
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
375369
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
376370
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=

trie/bintrie/internal_node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222

2323
"github.com/ethereum/go-ethereum/common"
24-
"github.com/zeebo/blake3"
24+
"crypto/sha256"
2525
)
2626

2727
func keyToPath(depth int, key []byte) ([]byte, error) {
@@ -104,7 +104,7 @@ func (bt *InternalNode) Copy() BinaryNode {
104104

105105
// Hash returns the hash of the node.
106106
func (bt *InternalNode) Hash() common.Hash {
107-
h := blake3.New()
107+
h := sha256.New()
108108
if bt.left != nil {
109109
h.Write(bt.left.Hash().Bytes())
110110
} else {

trie/bintrie/stem_node.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"slices"
2424

2525
"github.com/ethereum/go-ethereum/common"
26-
"github.com/zeebo/blake3"
26+
"crypto/sha256"
2727
)
2828

2929
// StemNode represents a group of `NodeWith` values sharing the same stem.
@@ -107,12 +107,12 @@ func (bt *StemNode) Hash() common.Hash {
107107
var data [NodeWidth]common.Hash
108108
for i, v := range bt.Values {
109109
if v != nil {
110-
h := blake3.Sum256(v)
110+
h := sha256.Sum256(v)
111111
data[i] = common.BytesToHash(h[:])
112112
}
113113
}
114114

115-
h := blake3.New()
115+
h := sha256.New()
116116
for level := 1; level <= 8; level++ {
117117
for i := range NodeWidth / (1 << level) {
118118
h.Reset()

trie/bintrie/trie_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestSingleEntry(t *testing.T) {
4242
if tree.GetHeight() != 1 {
4343
t.Fatal("invalid depth")
4444
}
45-
expected := common.HexToHash("694545468677064fd833cddc8455762fe6b21c6cabe2fc172529e0f573181cd5")
45+
expected := common.HexToHash("aab1060e04cb4f5dc6f697ae93156a95714debbf77d54238766adc5709282b6f")
4646
got := tree.Hash()
4747
if got != expected {
4848
t.Fatalf("invalid tree root, got %x, want %x", got, expected)
@@ -63,7 +63,7 @@ func TestTwoEntriesDiffFirstBit(t *testing.T) {
6363
if tree.GetHeight() != 2 {
6464
t.Fatal("invalid height")
6565
}
66-
if tree.Hash() != common.HexToHash("85fc622076752a6fcda2c886c18058d639066a83473d9684704b5a29455ed2ed") {
66+
if tree.Hash() != common.HexToHash("dfc69c94013a8b3c65395625a719a87534a7cfd38719251ad8c8ea7fe79f065e") {
6767
t.Fatal("invalid tree root")
6868
}
6969
}
@@ -190,7 +190,7 @@ func TestMerkleizeMultipleEntries(t *testing.T) {
190190
}
191191
}
192192
got := tree.Hash()
193-
expected := common.HexToHash("8c74de28e6bb6b2296cae37cff16266e2dbf533bc204fa4cb0c237761ae8a2c8")
193+
expected := common.HexToHash("9317155862f7a3867660ddd0966ff799a3d16aa4df1e70a7516eaa4a675191b5")
194194
if got != expected {
195195
t.Fatalf("invalid root, expected=%x, got = %x", expected, got)
196196
}

0 commit comments

Comments
 (0)