Skip to content

Commit 57bbdfc

Browse files
committed
fold use SubtreeConsistency for Consistency
1 parent 5899715 commit 57bbdfc

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
@@ -82,27 +82,7 @@ func SubtreeInclusion(index, start, end uint64) (Nodes, error) {
8282
// consistency proof between the two given tree sizes of a log Merkle tree. It
8383
// requires 0 <= size1 <= size2.
8484
func Consistency(size1, size2 uint64) (Nodes, error) {
85-
if size1 > size2 {
86-
return Nodes{}, fmt.Errorf("tree size %d > %d", size1, size2)
87-
}
88-
if size1 == size2 || size1 == 0 {
89-
return Nodes{IDs: []compact.NodeID{}}, nil
90-
}
91-
92-
// Find the root of the biggest perfect subtree that ends at size1.
93-
level := uint(bits.TrailingZeros64(size1))
94-
index := (size1 - 1) >> level
95-
// The consistency proof consists of this node (except if size1 is a power of
96-
// two, in which case adding this node would be redundant because the client
97-
// is assumed to know it from a checkpoint), and nodes of the inclusion proof
98-
// into this node in the tree of size2.
99-
p := nodes(index, level, size2)
100-
101-
// Handle the case when size1 is a power of 2.
102-
if index == 0 {
103-
return p.skipFirst(), nil
104-
}
105-
return p, nil
85+
return SubtreeConsistency(0, size1, size2)
10686
}
10787

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

0 commit comments

Comments
 (0)