Skip to content

Commit f602ae6

Browse files
committed
fold use SubtreeConsistency for Consistency
1 parent 754b77d commit f602ae6

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

proof/proof.go

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

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

0 commit comments

Comments
 (0)