Skip to content

State API to turn Merkle Path into Merkle Proof #21644

@edward-swirldslabs

Description

@edward-swirldslabs

As a follow up to issue #21030 and PR #21523, The State API needs a way to turn the Merkle Path long into a MerkleProof

The MerkleProof needs to have the following things:

  1. The StateItem as bytes or StateItem protobuf object or alternatively the MerkleLeaf containing a StateItem. Whichever form is easiest and the least computation to provide is fine.
  2. A List called siblingHashes from the leaf StateItem to the root of the state.
  3. A List<byte[]> of innerParentHashes where the following properties hold
  • innerParentHashes.get(0) == Hash(MerkleLeaf) or Hash(StateItem)
    • whichever is actually used for the hash of the leaf.
  • innerParentHashes.get(n+1) == Hash(innerParentHashes.get(n) [+] siblingHashes.get(n).hash())
    • where the order around [+] can be swapped based on whether the sibling hash is left or right.

A SiblingHash contains:

  1. A boolean indicating if its a right or left sibling
  2. The SHA-384 hash of the sibling in the merkle tree.

When hashing the StateItem and combining with the SiblingHashes in the order of the list, the root hash of the state should be derived.

  • This should be verified in unit tests for Singletons, Queues, and Maps.

Metadata

Metadata

Labels

PlatformTickets pertaining to the platform

Type

Projects

Status

🛠 In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions