Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Tree Tiger Hash and Merkle Hash Tree #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ivan386
Copy link

@ivan386 ivan386 commented Jun 13, 2018

multiformats/multihash#55

Merkle Hash Tree multihash

<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-<hash-mc>-<hash-len>-(<hash-value>)-[<hash-value>...])
<0x0400>-<len>-(<0x01>-<hash-mc>-<hash-len>-(<hash-value>)-[<hash-value>...])

0x0400 - Merkle Hash Tree (1024 decimal) multicodec value

0x01 - Hash Tree Type with this settings:

  • Data segment size - 1024 bytes
  • Data prefix - one byte with value 0 (0x00)
  • Hash pair prefix - one byte with value 1 (0x01)
  • Unpaired hashes move on next level unchanged.
  • hashes in tree packed in breadth-first order from root to leafs.

0x02 - Hash Tree Type with this settings:

  • Data segment size - 1024 bytes
  • Data prefix - one byte with value 0 (0x00)
  • Hash pair prefix - one byte with value 1 (0x01)
  • Unpaired hashes move on next level unchanged.
  • Level of hash tree
    1. level - 1 hash = root-hash
    2. level - 2 hashes
    3. level - 3-4 hashes
    4. level - 5-8 hashes
      and so on

Tiger multihash:

<tiger-mc>-<len>-<hash>
<0x7A>-<0x18>-<0x3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3>

0x7A - Tiger-hash multicodec value

Tree Tiger multihash:

<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-<tiger-mc><tiger-len>(<tiger-hash>)[<tiger-hash>...])

Tree sha2-256 multihash:

<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-<sha2-256-mc>-<sha2-256-len>-(<sha2-256-hash>)[<sha2-256-hash>...])

Links:

Tree Hash EXchange format (THEX)
Tiger:
A Fast New Cryptographic Hash Function (Designed in 1995)

wikipedia: Tiger (cryptography)
wikipedia: Merkle tree#Tiger tree hash

License: MIT
Signed-off-by: Ivan ivan386@users.noreply.github.com

multiformats/multihash#55

## Merkle Hash Tree multihash

`<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-(<multihash>[<multihash>...]))`
`<0x0400>-<len>-(<0x01>-(<multihash>[<multihash>...]))`

0x0400 - Merkle Hash Tree (1024 decimal) multicodec value 

0x01 - Hash Tree Type with this settings:
* Data segment size - 1024 bytes
* Data prefix - one byte with value 0 (0x00)
* Hash pair prefix - one byte with value 1 (0x01)
* Unpaired hashes move on next level unchanged.
* Multihashes in tree multihash packed in breadth-first order from root to leafs.

## Tiger multihash:

`<tiger-mc>-<len>-<hash>`
`<0x7A>-<0x18>-<0x3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3>`

0x7A - Tiger-hash multicodec value

## Tree Tiger multihash:
`<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-(<tiger-root-multihash>[<tiger-multihash>...]))`
## Tree sha2-256 multihash:
`<merkle-hash-tree-mc>-<len>-(<hash-tree-type>-(<sha2-256-root-multihash>[<sha2-256-multihash>...]))`

## Links:
[Tree Hash EXchange format (THEX)](https://adc.sourceforge.io/draft-jchapweske-thex-02.html#anchor2)
[Tiger:
A Fast New Cryptographic Hash Function (Designed in 1995)](http://www.cs.technion.ac.il/~biham/Reports/Tiger/)
wikipedia: [Tiger (cryptography)](https://en.wikipedia.org/wiki/Tiger_(cryptography))
wikipedia: [Merkle tree#Tiger tree hash](https://en.wikipedia.org/wiki/Merkle_tree#Tiger_tree_hash)

License: MIT
Signed-off-by: Ivan <ivan386@users.noreply.github.com>
@ivan386
Copy link
Author

ivan386 commented Dec 22, 2018

I write package that calc hash tree root: https://github.com/ivan386/go-hash-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants