Package org.symbol.sdk.symbol
Class Merkle
java.lang.Object
org.symbol.sdk.symbol.Merkle
- Merkle
- Merkle tree utilities for Symbol: merkle root building, merkle hash-chain proofs, and compact Patricia tree node types with deserialization and proof checking.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBranch node in a compact Patricia tree.static final classLeaf node in a compact Patricia tree.static final classBuilder for creating a merkle hash.static final recordRepresents part of a merkle tree proof.static final classPossible results of a patricia merkle proof.static final recordPath in a Patricia merkle tree.static classNode in a compact Patricia tree. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<Merkle.TreeNode> deserializePatriciaTreeNodes(byte[] buffer) Deserializes a buffer containing patricia tree nodes.static booleanproveMerkle(CryptoTypes.Hash256 leafHash, List<Merkle.MerklePart> merklePath, CryptoTypes.Hash256 rootHash) Proves a merkle hash.static intprovePatriciaMerkle(CryptoTypes.Hash256 encodedKey, CryptoTypes.Hash256 valueToTest, List<Merkle.TreeNode> merklePath, CryptoTypes.Hash256 stateHash, List<CryptoTypes.Hash256> subcacheMerkleRoots) Proves a patricia merkle hash.
-
Method Details
-
proveMerkle
public static boolean proveMerkle(CryptoTypes.Hash256 leafHash, List<Merkle.MerklePart> merklePath, CryptoTypes.Hash256 rootHash) - Merkle.proveMerkle
- Proves a merkle hash.
- Parameters:
leafHash- Leaf hash to prove.merklePath- Merkle hash chain from leaf to root.rootHash- Root hash of the merkle tree.- Returns:
trueif leaf hash is connected to root hash.
-
deserializePatriciaTreeNodes
- Merkle.deserializePatriciaTreeNodes
- Deserializes a buffer containing patricia tree nodes.
- Parameters:
buffer- Buffer containing serialized patricia tree nodes.- Returns:
- Deserialized patricia tree nodes.
-
provePatriciaMerkle
public static int provePatriciaMerkle(CryptoTypes.Hash256 encodedKey, CryptoTypes.Hash256 valueToTest, List<Merkle.TreeNode> merklePath, CryptoTypes.Hash256 stateHash, List<CryptoTypes.Hash256> subcacheMerkleRoots) - Merkle.provePatriciaMerkle
- Proves a patricia merkle hash.
- Parameters:
encodedKey- Encoded key of the state to prove.valueToTest- Expected hash of the state to prove.merklePath- Merkle node path from root to leaf.stateHash- State hash from a block header.subcacheMerkleRoots- Sub-cache merkle roots corresponding to the state hash.- Returns:
- Proof result code.
-