public BaselineTreeNode[] GetLeaves(params uint[] leafIndexes) { BaselineTreeNode[] leaves = new BaselineTreeNode[leafIndexes.Length]; for (int i = 0; i < leafIndexes.Length; i++) { leaves[i] = GetLeaf(leafIndexes[i]); } return(leaves); }
public BaselineTreeNode[] GetProof(uint leafIndex) { ValidateIndexAtRow(LeafRow, leafIndex); BaselineTreeNode[] proof = new BaselineTreeNode[TreeHeight]; uint indexAtRow = leafIndex; for (int proofRow = TreeHeight; proofRow > 0; proofRow--) { uint siblingIndex = GetSiblingIndexAtRow((uint)proofRow, indexAtRow); ulong siblingNodeIndex = GetNodeIndex((uint)proofRow, siblingIndex); ulong nodeIndex = GetNodeIndex((uint)proofRow, indexAtRow); Keccak hashAsKeccak = new Keccak(LoadValue(siblingNodeIndex).AsSpan().ToArray()); proof[TreeHeight - proofRow] = new BaselineTreeNode(hashAsKeccak, siblingNodeIndex); indexAtRow = GetIndexAtRow((uint)proofRow - 1u, GetParentIndex(nodeIndex)); } return(proof); }