@@ -21,7 +21,7 @@ func (pn *ProofNode) Hash() *felt.Felt {
21
21
return crypto .Pedersen (pn .Binary .LeftHash , pn .Binary .RightHash )
22
22
case pn .Edge != nil :
23
23
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
25
25
pathFelt := pn .Edge .Path .Felt ()
26
26
lengthFelt := new (felt.Felt ).SetBytes (length )
27
27
return new (felt.Felt ).Add (crypto .Pedersen (pn .Edge .Child , & pathFelt ), lengthFelt )
@@ -55,7 +55,6 @@ type Edge struct {
55
55
Value * felt.Felt
56
56
}
57
57
58
- // Edge nodes are defined as having a child with len greater than 1 from the parent
59
58
func isEdge (sNode storageNode , nodeNumFromRoot int ) bool {
60
59
sNodeLen := sNode .key .len
61
60
leftKey := sNode .node .Left .len
@@ -69,6 +68,8 @@ func isEdge(sNode storageNode, nodeNumFromRoot int) bool {
69
68
return false
70
69
}
71
70
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.
72
73
func getChildHash (tri * Trie , sNode storageNode , childKey * Key , nodeNumFromRoot int ) (* felt.Felt , error ) {
73
74
childNode , err := tri .GetNodeFromKey (childKey )
74
75
if err != nil {
@@ -105,8 +106,7 @@ func GetProof(leaf *felt.Felt, tri *Trie) ([]ProofNode, error) {
105
106
// -> Child should be leaf (len=251). Distance between child and parent should be > 1.
106
107
107
108
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
+
110
110
leftHash , err := getChildHash (tri , sNode , sNode .node .Left , i )
111
111
if err != nil {
112
112
return nil , err
0 commit comments