**Algorithm A1:** Initialization


```
Algorithm A2: Commitment and Construction of MerkleTree
```

```
Function Commitment(txArray):
   hashArray ← CalcHashForTxs(txArray)
   return CommitRecursively(hashArray)
Function CommitRecursively(layer):
   i ← 0
   def aultSibling ← sha256(constantA)
   while i < sizeOf(layer) do
       if layer[i + 1] exists then
           if layer[i] < layer[i+1] then
               upperLayer[ i2 ] ← sha256(layer[i] || layer[i + 1])
           else
               upperLayer[ i2 ] ← sha256(layer[i + 1] || layer[i])
           end
           layer[i].parent ← upperLayer[ i2 ] /* Record the node's parent */
           layer[i].sibling ← layer[i + 1] /* Record the node's sibling */
           layer[i + 1].parent ← upperLayer[ i2 ]
           layer[i + 1].sibling ← layer[i]
       else
           if layer[i] < defaultSibling then
               upperLayer[ i2 ] ← sha256(layer[i] || def aultSibling)
           else
               upperLayer[ i2 ] ← sha256(def aultSibling || layer[i])
           end
           layer[i].parent ← upperLayer[ i2 ]
           layer[i].sibling ← def aultSibling
       end
       i ← i + 2
   end
   MerkleTree.layerArray.append(layer) /* Save current layer to
    MerkleTree */
   if 1 = sizeO f(upperLayer) then
       MerkleTree.layerArray.append(upperLayer) /* Save the upper layer
        to MerkleTree */
       return upperLayer[0]
   else
       return CommitRecursively(upperLayer)
   end
```
**Algorithm A3:** Open

```
Function Open(i, txArray):
   hashArray ← CalcHashForTxs(txArray)
   proo f Array ← emptyArray
   return GetProo f Recursive(hashArray[i], proo f Array)
Function GetProofRecursively(node, proo f Array):
   sibling ← MerkelTree.getSibling(node) /* Find the node's sibling */
   if sibling dose not exist then
       return proo f Array
   else
       proo f Array.append(sibling)
       parent ← MerkelTree.getParent(node) /* Find the node's parent */
       return GetProo f Recursively(parent, proo f Array)
   end
```