Repository navigation
3. Parameters
Yves Hoebeke edited this page Jul 22, 2024
·
8 revisions
There are 3 mandatory parameters and 1 optional.
They are, in order:
- data
- algorithm
- process type
Expected data type: [][]byte(1)
(1)If empty will raise the empty list error.
Accepts a string that denotes the desired hashing algorithm. The following functionalities are in the registry:
| Ident(2) | import | syntax |
|---|---|---|
| MD5 | crypto/md5 |
md5.Sum(data) |
| SHA1 | crypto/sha1 |
sha1.Sum(data) |
| SHA3SUM256 | golang.org/x/crypto/sha3 |
sha3.Sum256(data) |
| SHA256SUM256 | crypto/sha256 |
sha256.Sum256(data) |
| SHA512SUM256 | crypto/sha512 |
sha512.Sum256(data) |
| SHA512SUM512 | crypto/sha512 |
sha512.Sum512(data) |
(2)Will raise an unknown hash algorithm error if no match is found.
Note:
- Other schemes can be added by editing the
cryptofuncs.gosource. - Registry signature:
var AlgorithmRegistry map[string]CryptoFunc - Function signature:
type CryptoFunc func([]byte) []byte
There are 3 process types that can be specified. Each one will handle unbalanced trees in it's own manner:
| Value(3) | Process Name |
|---|---|
| 0 | Pass Through |
| 1 | Duplicate and Append |
| 2 | Binary Tree |
(3)Incorrect value will raise the invalid process type error.
Notes:
- Processing the same input data and subjecting it to different Process Types will obviously result in different Merkle Root values.
- To the best of my knowledge, at the time of this writing, the Bitcoin cryptocurrency/blockchain uses "Duplicate and Append" method and "Pass Through" is used in the Monero cryptocurrency/blockchain.
github.com/yveshoebeke/merkletree