Skip to content

Commit df8e3fe

Browse files
committed
fold use SubtreeConsistency for Consistency
1 parent 93b9b37 commit df8e3fe

1 file changed

Lines changed: 1 addition & 24 deletions

File tree

proof/proof.go

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,7 @@ func SubtreeInclusion(index, start, end uint64) (Nodes, error) {
8484
// consistency proof between the two given tree sizes of a log Merkle tree. It
8585
// requires 0 < size1 <= size2.
8686
func Consistency(size1, size2 uint64) (Nodes, error) {
87-
if size1 > size2 {
88-
return Nodes{}, fmt.Errorf("tree size %d > %d", size1, size2)
89-
}
90-
if size1 == 0 {
91-
return Nodes{}, fmt.Errorf("consistency proof from an empty tree is meaningless")
92-
}
93-
if size1 == size2 {
94-
return Nodes{IDs: []compact.NodeID{}}, nil
95-
}
96-
97-
// Find the root of the biggest perfect subtree that ends at size1.
98-
level := uint(bits.TrailingZeros64(size1))
99-
index := (size1 - 1) >> level
100-
// The consistency proof consists of this node (except if size1 is a power of
101-
// two, in which case adding this node would be redundant because the client
102-
// is assumed to know it from a checkpoint), and nodes of the inclusion proof
103-
// into this node in the tree of size2.
104-
p := nodes(index, level, size2)
105-
106-
// Handle the case when size1 is a power of 2.
107-
if index == 0 {
108-
return p.skipFirst(), nil
109-
}
110-
return p, nil
87+
return SubtreeConsistency(0, size1, size2)
11188
}
11289

11390
// SubtreeConsistency returns the information on how to fetch and construct a

0 commit comments

Comments
 (0)