# Functions
AddHashedLeaf adds a single leaf to the mmr and back fills any interior nodes 'above and to the left'
Returns the size of the mmr after addition of the leaf.
No description provided by the author
No description provided by the author
BagPeaksRHS computes a root for the RHS peaks.
No description provided by the author
No description provided by the author
CheckConsistency verifies that the current state mmrSizeB is consistent with the provided accumulator for the earlier size A The provided accumulator (peakHashesA) should be taken from a trusted source, typically a signed mmr state.
CheckConsistencyBagged is used to check that a new log update is consistent With respect to some previously known "bagged" root and the current store.
ConsistentRoots is supplied with the accumulator from which consistency is being shown, and an inclusion proof for each accumulator entry in a future MMR state.
FirstMMRSize returns the first complete MMRSize that contains the provided mmrIndex.
GetLeafProofRoot gets the appropriate peak root from peakHashes for a leaf proof, See GetProofPeakRoot.
GetLeafProofRoot gets the compressed accumulator peak index for a leaf proof, See GetProofPeakRoot.
GetProofPeakRoot returns the peak hash for sub tree committing any node.
GetRoot returns the root hash for the Merkle Mountain Range.
HashPeaksRHS merkleizes the peaks to obtain a single tree root This variant copies the peakHashes list in order to be side effect free.
HashPosPair64 returns H(pos || a || b) ** the hasher is reset **.
HashWriteUInt64 writes a uint64 to a hasher in bigendian layout - most significant byte at lowest address/storage location.
HeightIndexLeafCount returns the count of leaves that are contained in a single mountain whose height is heightIndex + 1.
HeightIndexSize returns the node count corresponding to the zero based height index.
HeightMaxIndex returns the node index corresponding to the zero based height index.
HeightSize returns the size of the mmr with the provided height.
IncludedRoot calculates the accumulator peak for the provided proof and node value.
IndexPath collects the merkle proof mmr index i
For the following index tree, and i=15 with mmrSize = 26 we would obtain the path
[H(16), H(20)]
Because the accumulator peak committing 15 is 21, and given the value for 15, we only need 16 and then 20 to verify the proof.
InclusionProofBagged provides a proof of inclusion for the leaf at index i against the full MMR
It relies on the methods InclusionProofLocal, BagPeaksRHS and PeaksLHS for collecting the necessary MMR elements and then combines the results into a final verifiable commitment for the whole MMR.
InclusionProofLocal collects the merkle root proof for the local MMR peak containing index i
So for the follwing index tree, and i=15 with mmrSize = 26 we would obtain the path
[H(16), H(20)]
Because the local peak is 21, and given the value for 15, we only need 16 and then 20 to prove the local root.
InclusionProofLocalExtend produces a proof which can verify for two mmr sizes It shows that the proof for mmrSizeB is an *extention* of the proof for mmrSizeA.
InclusionProofLocalOld is depreciated and retained only for testing See InclusionProofLocal instead
collects the merkle root proof for the local MMR peak containing index i
So for the follwing index tree, and i=15 with mmrSize = 26 we would obtain the path
[H(16), H(20)]
Because the local peak is 21, and given the value for 15, we only need 16 and then 20 to prove the local root.
returns the mmr indices identifying the witness nodes for mmr index i
This method allows tooling to individually audit the proof path node values for a given index.
IndexConsistencyProof creates a proof that mmr B appends to mmr A.
IndexConsistencyProofBagged creates a proof that mmr B appends to mmr A.
IndexHeight obtains the tree height of an MMR index Taking advantage of the binary encoding resulting from the tree construction to do so.
IndexHieght2 obtains the tree height of an MMR index (position - 1) Then, we iteratively reduce the size to the next perfect tree down.
IsPow2 determins if the unsigned value size is a perfect power of 2.
JumpLeftPerfect is used to iteratively discover the left most node at the same height as the node identified by pos.
JumpRightSibling moves from pos to the next sibling at the same height.
LeafCount returns the number of leaves in the largest mmr whose size is <= the supplied size.
No description provided by the author
LeafMinusSpurSum returns the number of peaks preceding iLeaf that the future tree requires.
No description provided by the author
LeftChild returns the position of the top most left child of parent pos.
LeftPosForHeight returns the position that is 'most left' for the given height.
No description provided by the author
Log2Uint64 efficiently computes log base 2 of num.
MaxPeakHeight obtains the hight index of the highest (and left most peak) for the mmr index i.
MMRIndex returns the node index for the leaf e
Args: - leafIndex: the leaf index, where the leaves are numbered consequtively, ignoring interior nodes.
No description provided by the author
PeakBagRHS collects the peaks for BagPeaksRHS in the right order for hashing.
No description provided by the author
PeakIndex returns the index of the peak accumulator for the peak with the provided proof length.
Peaks returns the array of mountain peak indices in the MMR.
PeaksBitmap returns a bit mask where a 1 corresponds to a peak and the position of the bit is the height of that peak.
PeaksLHS collects the peaks to the left of position pos into a flat sequence
So for the following tree and pos=25 we would get
[15, 22]
3 15 / \ / \ / \ 2 7 14 22 / \ / \ / \ 1 3 6 10 13 18 21 25 / \ / \ / \ / \ / \ / \ / \ 0 1 2 4 5 8 9 11 12 16 17 19 20 23 24 26.
PeaksOld is deprecated and retained only for reference and testing.
PosHeight is used when position is a 1 based count.
PosPeaks is a depricated version of peaks which returns an array of mmr positions rather than indices.
SiblingOffset returns the offset to the sibling at the given height.
SpurHeightLeaf returns the number of nodes 'above' and to the *left* of the provided leaf index
Notice this is the leaf index as tho the leaves were in their own array rather than the mmr index
considering the following mmr
3 14 29 / \ \ / \ / \ / \ / \ 2 6 .
SpurSumHeight counts the interior 'spur' nodes required for the given height The height is typically relative to the massif height.
TopHeight returns the index height of the largest perfect peak contained in, or exactly, pos This is essentially a ^2 *floor* function for the accumulation of bits:
TopHeight(0) = TopHeight(1) = 0 TopHeight(1) = TopHeight(2) = TopHeight(3) = TopHeight(4) = TopHeight(5) = 1 TopHeight(6) = 2
2 6 / \ 1 2 5 9 / \ / \ / \ 0 0 1 3 4 7 8 10.
TopPeak returns the smallest, leftmost, peak containing *or equal to* i
This is essentially a ^2 *floor* function for the accumulation of bits:
TopPeak(0) = TopPeak(1) = 0 TopPeak(1) = TopPeak(2) = TopPeak(3) = TopPeak(4) = TopPeak(5) = 2 TopPeak(6) = 6
2 6 / \ 1 2 5 9 / \ / \ / \ 0 0 1 3 4 7 8 10.
TreeIndex returns the mmr index of the i'th leaf It can also be used to calculate the sum of all the 'alpine nodes' in the mmr blobs preceding the blob if the blob index is substituted for iLeaf.
VerifyConsistency verifies the consistency between two MMR states.
VerifyConsistencyBagged returns true if the mmr log update from mmr a to mmr b is append only.
VerifyFirstInclusionPathBagged process the proof until it re-produces the "bagged" root of the MMR
This method exists for the situation where multiple, possibly related, proofs are catenated together in the same path.
No description provided by the author
VerifyInclusionBagged returns true if the provided proof demonstrates inclusion of nodeHash at position iLeaf+1
proof and root should be obtained via InclusionProof and GetRoot respectively.
VerifyInclusionOld returns true if the provided proof demonstrates inclusion of nodeHash at position iLeaf+1
proof and root should be obtained via InclusionProof and GetRoot respectively.
VerifyInclusionPath returns true if the leafHash combined with path, reproduces the provided root
To facilitate the concatenated proof paths used for consistency proofs, it returns the count of path elements used to reach the root.
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
ConsistencyProof describes a proof that the merkle log defined by size a is perfectly contained in the log described by size b.
No description provided by the author
# Interfaces
No description provided by the author