Skip to content

Commit f3d9d57

Browse files
committed
wire: change leafhash to use taggedhash
1 parent 7df8b9c commit f3d9d57

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

wire/leaf.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package wire
66

77
import (
88
"bytes"
9-
"crypto/sha512"
109
"encoding/hex"
1110
"encoding/json"
1211
"fmt"
@@ -115,14 +114,11 @@ func (l *LeafData) UnmarshalJSON(data []byte) error {
115114

116115
// LeafHash concats and hashes all the data in LeafData.
117116
func (l *LeafData) LeafHash() [32]byte {
118-
digest := sha512.New512_256()
119-
l.Serialize(digest)
120-
121-
// TODO go 1.17 support slice to array conversion so we
122-
// can avoid this extra copy.
123-
hash := [32]byte{}
124-
copy(hash[:], digest.Sum(nil))
125-
return hash
117+
return *chainhash.TaggedHash512_256(chainhash.TagUtreexoV1,
118+
func(w io.Writer) {
119+
l.Serialize(w)
120+
},
121+
)
126122
}
127123

128124
// ToString turns a LeafData into a string for logging.

0 commit comments

Comments
 (0)