Skip to content

Commit 89a59d6

Browse files
committed
fold use SubtreeConsistency for Consistency
1 parent 19a155a commit 89a59d6

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
@@ -84,27 +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 == size2 || size1 == 0 {
91-
return Nodes{IDs: []compact.NodeID{}}, nil
92-
}
93-
94-
// Find the root of the biggest perfect subtree that ends at size1.
95-
level := uint(bits.TrailingZeros64(size1))
96-
index := (size1 - 1) >> level
97-
// The consistency proof consists of this node (except if size1 is a power of
98-
// two, in which case adding this node would be redundant because the client
99-
// is assumed to know it from a checkpoint), and nodes of the inclusion proof
100-
// into this node in the tree of size2.
101-
p := nodes(index, level, size2)
102-
103-
// Handle the case when size1 is a power of 2.
104-
if index == 0 {
105-
return p.skipFirst(), nil
106-
}
107-
return p, nil
87+
return SubtreeConsistency(0, size1, size2)
10888
}
10989

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

0 commit comments

Comments
 (0)