-
Notifications
You must be signed in to change notification settings - Fork 114
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 Tiger Tree Hash and Merkle Hash Tree #55
Comments
Short summary: we might need to allocate new numbers for:
Long comment: I have investigated the situation and propose the following algorithm. A special hashing function introduced that is only supposed to be able to hash Blob and List. Contrary to normal hashing functions it has ProtoBuf parser built-in to handle Blob and List. If this parser meets octet sequence, that is Blob, and TTH Leaf is being calculated for Blob.data (but not for ProtoBuf bytes describing length of Blob). If this parser meets array, that is List, and it prepares to calculate TTH Node. In case of unexpected byte sequence a fallback is possible. I have thought about the possibility to provide several ProtoBuf List descriptions with different sizes, and a hacked TTH might match all of them to the same TTH, and that can be used for tricking IPFS, which is not good. So I have decided to extend TTH with size, and fallback should happen when any tampering with sizes detected. Real tools having TTH often also have size, so they can always construct IPFS hash from TTH and size. UPD. Oh, I see. So now it's CBOR, not ProtoBuf. Alright, anyway TTH (24 bytes) + size (8 bytes) = 32 bytes, that should be IPFS hash for Merkle tree of properly hashed file. We just need a number to prepend. |
Merkle Hash Tree (1024)Segment size - 1024 bytes ++ - concatenation Leaf hash: Hash( 0x00 ++ ( data 1024 bytes or less if this is last segment ) )
Links:Tree Hash EXchange format (THEX) |
@Stebalien |
(not quite dead, just 6 feet under github notifications ⚰️) I'm not sure if we need to allocate a range of codecs. I'd just define a new code per hash type and stick all the format-specific options inside the hash itself. For example, one might want a digest (just the root):
Or a serialized tree:
Does that sound reasonable or am I missing something? |
Merkle Hash Tree multihash
0x0400 - Merkle Hash Tree (1024 decimal) multicodec value 0x01 - Hash Tree Type with this settings:
breadth-first order:
0x02 - Hash Tree Type with this settings:
Tiger multihash:
0x7A - Tiger-hash multicodec value Tree Tiger multihash:
Tree sha2-256 multihash:
|
multiformats#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>
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>
multiformats#55 License: MIT Signed-off-by: Ivan <ivan386@users.noreply.github.com>
Go tiger hash: https://github.com/cxmcc/tiger |
@Stebalien I write spec for that case: https://github.com/ivan386/multihash-tree |
@jbenet
The Tiger tree hash is a widely used form of hash tree. It uses a binary hash tree (two child nodes under each node), usually has a data block size of 1024 bytes and uses the cryptographically secure Tiger hash.
Tiger tree hashes are used in Gnutella, Gnutella2, and Direct Connect P2P file sharing protocols and in file sharing applications such as Phex, BearShare, LimeWire, Shareaza, DC++ and Valknut.
Example:
RBOEI7UYRYO5SUXGER5NMUOEZ5O6E4BHPP2MRFQ
Short name: TTH
Alternative name: Tree Tiger Hash
URN:
urn:tree:tiger:[TTH in base32]
Magnet:
magnet:?xt=urn:tree:tiger:[TTH in base32]
Default size: 192 bits
Default encoding: Base32
The text was updated successfully, but these errors were encountered: