# SASLedger: A Secured, Accelerated Scalable Storage Solution for Distributed Ledger Systems
## Appendix A  
In the following algorithms, \"=\" means \"equals to\" and \"\(||\)\" means \"concatenation\". ```
\(txArray\leftarrow[tx_{1},...,tx_{n}]\) \(MerkleTree.layerArray\gets emptyArray\) /* Initialize the layers of the MerkleTree with an empty array */ FunctionCalcHashForTxs(\(txArray\)): \(i\gets 0\) while\(i<sizeOf(txArray)\)do \(hashArray[i]\gets sha256(txArray[i]\ ||\ i)\(i\gets i+1\) end while return\(hashArray\)
```  
**Algorithm A1**Initialization  
```
\(txArray\gets[tx_{1},...,tx_{n}]\) \(MerkleTree.layerArray\gets emptyArray\) /* Initialize the layers of the MerkleTree with an empty array */ FunctionCalcHashForTxs(\(txArray\)): \(i\gets 0\) while\(i<sizeOf(txArray)\)do \(hashArray[i]\gets sha256(txArray[i]\ ||\ i)\) \(i\gets i+1\) end while return\(hashArray\)
```  
**Algorithm 1**Initialization```
FunctionCommitment(\(txArray\)): \(hashArray\gets CalcHashForTxs(txArray)\) return\(CommitRecursively(hashArray)\) FunctionCommitRecursively(\(layer\)): \(i\gets 0\) \(defaultSibling\gets sha256(constantA)\) while\(i\)<sizeOf(\(layer\))do if\(layer[i+1]\)existsthen if\(layer[i]\)<\(layer[i+1]\)then \(upperLayer[\frac{i}{2}]\gets sha256(layer[i]\mid layer[i+1])\) else \(upperLayer[\frac{i}{2}]\gets sha256(layer[i+1]\mid layer[i])\)  end if \(layer[i].parent\gets upperLayer[\frac{i}{2}]\) /* Record the node's parent */ \(layer[i].sibling\gets layer[i+1]\) /* Record the node's sibling */ \(layer[i+1].parent\gets upperLayer[\frac{i}{2}]\) \(layer[i+1].sibling\gets layer[i]\) else if\(layer[i]\)<\(defaultSibling\)then \(upperLayer[\frac{i}{2}]\gets sha256(layer[i]\mid defaultSibling)\) else \(upperLayer[\frac{i}{2}]\gets sha256(defaultSibling\mid layer[i])\)  end if \(layer[i].parent\gets upperLayer[\frac{i}{2}]\) \(layer[i].sibling\gets defaultSibling\)  end if \(i\gets i+2\)  end if \(MerkleTree.layerArray.append(layer)\) /* Save current layer to MerkleTree */ if\(1=sizeOf(upperLayer)\)then \(MerkleTree.layerArray.append(upperLayer)\) /* Save the upper layer to MerkleTree */ return\(upperLayer[0]\) else return\(CommitRecursively(upperLayer)\)  end if
```

**Algorithm A2**Commitment and Construction of MerkleTree```
FunctionOpen(\(i,txArray\)): \(hashArray\leftarrow CalcHashForTxs(txArray)\) \(proofArray\gets emptyArray\) return\(GetProof\,Recursive(hashArray[i],proof\,Array)\) FunctionGetProofRecursively(\(node,proof\,Array\)): \(sibling\leftarrow\)\(\mathit{MerkelTree.getSibling}(node)\) /* Find the node's sibling */ if\(sibling\)\(\mathit{dose}\)\(\mathit{not}\)\(\mathit{exist}\)then return\(proof\,Array\) else \(proof\,Array\)\(\mathit{append}(sibling)\) \(parent\leftarrow\mathit{MerkelTree.getParent}(node)\) /* Find the node's parent */ return\(GetProof\,Recursively(parent,proof\,Array)\)  end if
```  
**Algorithm A3**Open  
```
FunctionVerify(\(C,i,tx,proof\,Array\)): \(result\gets\mathit{sha256}(tx\mid\mid i)\) \(j\gets 0\) while\(j\)< %izeOf(\(\mathit{proofArray}\))do if\(\mathit{result}\)< \(\mathit{proofArray}[j]\)then \(result\leftarrow\mathit{hash256}(\mathit{result}\mid\mid proof\,Array[j])\) else \(result\leftarrow\mathit{hash256}(\mathit{proof\,Array[j]}\mid\mid\mathit{ result})\)  end if \(j\gets j+1\) end if if\(C\)= \(\mathit{result}\)then return\(1\) else return\(0\) end
```  
**  
* [PERSON] et al. (2018) [PERSON]; [PERSON]; [PERSON]; [PERSON]; [PERSON] Sharding blockchain. In Proceedings of the 2018 IEEE International Conference on Internet of Things (IThings) and IEEE Green Computing and Communications (GreenCom) and IEEE Cyber, Physical and Social Computing (CPSCom) and IEEE Smart Data (SmartData), Halifax, NS, Canada, 30 July-3 August 2018; p. 1665. * [PERSON] and [PERSON] (2019) [PERSON]; [PERSON] Monoxide: Scale out blockchains with asynchronous consensus zones. In Proceedings of the 16 th USENIX Symposium on Networked Systems Design and Implementation (NSDI), Boston, MA, USA, 26-28 February 2019; pp. 95-112. * [PERSON] et al. (2018) [PERSON]; [PERSON]; [PERSON] CUB, a consensus unit-based storage scheme for blockchain system.