Skip to content

Commit

Permalink
fix absent keys in proofs
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
  • Loading branch information
jsign committed Oct 15, 2023
1 parent 0d744bd commit 68ebe55
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ func (n *InternalNode) CreatePath(path []byte, stemInfo stemInfo, comms []*Point
n.children[path[0]] = Empty{}
case extStatusAbsentOther:
// insert poa stem
newchild := &LeafNode{
commitment: comms[0],
stem: stemInfo.stem,
values: nil,
depth: n.depth + 1,
}
n.children[path[0]] = newchild
comms = comms[1:]
newchild.c1 = new(Point)
newchild.c2 = new(Point)
case extStatusPresent:
// insert stem
newchild := &LeafNode{
Expand Down Expand Up @@ -1375,10 +1385,15 @@ func (n *LeafNode) GetProofItems(keys keylist, _ NodeResolverFn) (*ProofElements
// First pass: add top-level elements first
var hasC1, hasC2 bool
for _, key := range keys {
hasC1 = hasC1 || (key[31] < 128)
hasC2 = hasC2 || (key[31] >= 128)
if hasC2 {
break
// Note that keys might contain keys that don't correspond to this leaf node.
// We should only analize the inclusion of C1/C2 for keys corresponding to this
// leaf node stem.
if equalPaths(n.stem, key) {
hasC1 = hasC1 || (key[31] < 128)
hasC2 = hasC2 || (key[31] >= 128)
if hasC2 {
break
}
}
}
if hasC1 {
Expand Down

0 comments on commit 68ebe55

Please sign in to comment.