ProofError
Git Source (opens in a new tab)
enum ProofError {
NONE,
InvalidProofLeafIdxOutOfBounds,
InvalidProofBadLeftRange,
InvalidProofBadRightRange,
InvalidProofUnrecognizedRoot
}
decomposeNonZeroInterval
Git Source (opens in a new tab)
seedHeight=
Helper for calculating range size for a non-zero-starting interval.
The bitmath here decomposes the interval into two parts that in combination represent the compact range needed to express the interval.
function decomposeNonZeroInterval(uint256 begin, uint256 end) pure returns (uint256 left, uint256 right);
Parameters
Name | Type | Description |
---|---|---|
begin | uint256 | The start of the interval of the range's coverage (inclusive). |
end | uint256 | The end of the interval of the range's coverage (exclusive). |
Returns
Name | Type | Description |
---|---|---|
left | uint256 | Bitmap representing the left part of the interval. |
right | uint256 | Bitmap representing the right part of the interval. |
validateProof
Git Source (opens in a new tab)
function validateProof(Proof calldata proof, uint256 targetTreeSize) pure returns (ProofError);
merge
Git Source (opens in a new tab)
Merges two compact ranges along a given seed node.
Merge folds hashes in from leftRange and rightRange into seed in order to create a combined compact range. The merged range is left + seed + right. leftRange is assumed to start its coverage at index 0.
function merge(
bytes32[] calldata leftRange,
bytes32 seed,
uint256 seedHeight,
uint256 seedIndex,
bytes32[] calldata rightRange,
uint256 rightRangeEnd
)
pure
returns (bytes32[] calldata left, bytes32 newSeed, bytes32[] calldata right);
Parameters
Name | Type | Description |
---|---|---|
leftRange | bytes32[] | The left compact range to merge. |
seed | bytes32 | The seed node to merge along. |
seedHeight | uint256 | The height of the seed node. |
seedIndex | uint256 | The index of the seed node. |
rightRange | bytes32[] | The right compact range to merge. |
rightRangeEnd | uint256 | The end of the right range's coverage. |
Returns
Name | Type | Description |
---|---|---|
left | bytes32[] | The left portion of the merged compact range. |
newSeed | bytes32 | The new seed node of the merged range. |
right | bytes32[] | The right portion of the merged compact range. |
getRangeSizeForNonZeroBeginningInterval
Git Source (opens in a new tab)
Returns the expected size of a compact range needed to express a non-zero-starting interval.
function getRangeSizeForNonZeroBeginningInterval(uint256 start, uint256 end) pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
start | uint256 | The start of the interval of the range's coverage (inclusive). |
end | uint256 | The end of the interval of the range's coverage (exclusive). |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | size The size of the compact range needed to express the interval [start, end). |
hashToParent
Git Source (opens in a new tab)
Hashes two bytes32s together as into a merkle parent.
function hashToParent(bytes32 left, bytes32 right) pure returns (bytes32 parent);
Parameters
Name | Type | Description |
---|---|---|
left | bytes32 | The left child to hash. |
right | bytes32 | The right child to hash. |
Returns
Name | Type | Description |
---|---|---|
parent | bytes32 | The parent hash. |
ProofErrors
Git Source (opens in a new tab)
enum ProofErrors {
NONE,
InvalidProofLeafIdxOutOfBounds,
InvalidProofBadLeftRange,
InvalidProofBadRightRange,
InvalidProofUnrecognizedRoot
}
getRoot
Git Source (opens in a new tab)
Returns the root for a given compact range.
This method "bags the peaks" of the compact range, folding in from R2L.
function getRoot(bytes32[] calldata hashes) pure returns (bytes32 root);
Parameters
Name | Type | Description |
---|---|---|
hashes | bytes32[] | The hashes of the compact range to calculate the root for. |
Returns
Name | Type | Description |
---|---|---|
root | bytes32 | The root of the compact range. |
getRootForMergedRange
Git Source (opens in a new tab)
Utility for calculating the root of a compact range provided in a gas-convenient representation.
function getRootForMergedRange(
bytes32[] calldata leftRange,
bytes32 seed,
bytes32[] calldata rightRange
)
pure
returns (bytes32 root);
Parameters
Name | Type | Description |
---|---|---|
leftRange | bytes32[] | The left portion of the compact range to merge. |
seed | bytes32 | The middle portion of the compact range to merge. |
rightRange | bytes32[] | The right portion of the compact range to merge. |
Returns
Name | Type | Description |
---|---|---|
root | bytes32 | The calculated root of the compact range. |