A consistency proof lets someone holding an old root confirm the new tree only appended - it did not rewrite history. Today you build that check for a power-of-two old size.
Verify that an old root is consistent with a new tree by checking the new tree kept it as a prefix subtree.
A consistency proof answers a sharper question than “did anything change?” It asks
“was the change only an append?” Someone who trusts the old root wants assurance that
the new, larger tree still contains the old one as a prefix - that no old entry was
quietly edited or deleted. For an old size m that is a power of two, the old root is
exactly the new tree’s subtree over [0, m), so the check is one SubtreeRoot
comparison.
When the new data is a true append (alice, bob then + carol, dave), the [0, 2)
subtree still hashes to 0xebb8e925 and consistency holds. But swap bob for bib
and that prefix subtree hash changes, so the check returns false - the log rewrote
history and is caught. Real consistency proofs (RFC 6962) generalize this to any old
size by shipping a handful of subtree hashes instead of the whole new tree; this
power-of-two version is the honest core of the idea.
// old size m must be a power of two here; the old root covers leaves [0, m).func VerifyConsistency(oldRoot Hash, newData [][]byte, m int) bool {return Build(newData).SubtreeRoot(0, m) == oldRoot}