Class Merkle

java.lang.Object
org.symbol.sdk.symbol.Merkle

public final class Merkle extends Object
Merkle

Merkle tree utilities for Symbol: merkle root building, merkle hash-chain proofs, and compact Patricia tree node types with deserialization and proof checking.

  • 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:

      true if leaf hash is connected to root hash.

    • deserializePatriciaTreeNodes

      public static List<Merkle.TreeNode> deserializePatriciaTreeNodes(byte[] buffer)
      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.