Skip to content

Commit 295fd38

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

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

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)