Skip to content

Commit d242797

Browse files
author
rian
committed
comment
1 parent 0b38801 commit d242797

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/trie/proof.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (pn *ProofNode) Hash() *felt.Felt {
2121
return crypto.Pedersen(pn.Binary.LeftHash, pn.Binary.RightHash)
2222
case pn.Edge != nil:
2323
length := make([]byte, len(pn.Edge.Path.bitset))
24-
length[31] = pn.Edge.Path.len
24+
length[len(pn.Edge.Path.bitset)-1] = pn.Edge.Path.len
2525
pathFelt := pn.Edge.Path.Felt()
2626
lengthFelt := new(felt.Felt).SetBytes(length)
2727
return new(felt.Felt).Add(crypto.Pedersen(pn.Edge.Child, &pathFelt), lengthFelt)
@@ -55,7 +55,6 @@ type Edge struct {
5555
Value *felt.Felt
5656
}
5757

58-
// Edge nodes are defined as having a child with len greater than 1 from the parent
5958
func isEdge(sNode storageNode, nodeNumFromRoot int) bool {
6059
sNodeLen := sNode.key.len
6160
leftKey := sNode.node.Left.len
@@ -69,6 +68,8 @@ func isEdge(sNode storageNode, nodeNumFromRoot int) bool {
6968
return false
7069
}
7170

71+
// The binary node uses the hash of children. If the child is an edge, we first need to represent it
72+
// as an edge node, and then take its hash.
7273
func getChildHash(tri *Trie, sNode storageNode, childKey *Key, nodeNumFromRoot int) (*felt.Felt, error) {
7374
childNode, err := tri.GetNodeFromKey(childKey)
7475
if err != nil {
@@ -105,8 +106,7 @@ func GetProof(leaf *felt.Felt, tri *Trie) ([]ProofNode, error) {
105106
// -> Child should be leaf (len=251). Distance between child and parent should be > 1.
106107

107108
for i, sNode := range nodesExcludingLeaf {
108-
// The binary node uses the hash of children. If the child is an edge, we represent it
109-
// as an edge, and then take its hash.
109+
110110
leftHash, err := getChildHash(tri, sNode, sNode.node.Left, i)
111111
if err != nil {
112112
return nil, err

0 commit comments

Comments
 (0)