multiformats / multicodec

Compact self-describing codecs. Save space by using predefined multicodec tables.
MIT License
336 stars 201 forks source link

Error in table.csv with blake2b-256 #257

Closed On1x closed 2 years ago

On1x commented 2 years ago

It's have code 0xb220, but it not decoded by other software.

Example: bafykbzacec5z3vyrefc7vcbfcyjpj2zt3vikgk5v3p3hpwdtxi3moqqpcfoci https://cid.ipfs.io/#bafykbzacec5z3vyrefc7vcbfcyjpj2zt3vikgk5v3p3hpwdtxi3moqqpcfoci It say that it MULTIHASH CODE: 0xb220, but it really 0xa0e402.

bafykbzacec5z3vyrefc7vcbfcyjpj2zt3vikgk5v3p3hpwdtxi3moqqpcfoci remove b as first symbol and base32 decode give a hex: 0170a0e40220bb9dd7112145fa88251612f4eb33dd50a32bb5dbf677d873ba36c7420f115c24

Where: 01 - CID version 70 - content type: dag-pb MerkleDAG protobuf a0e402 - blake2b-256 ??? why not b220 20 - hash length bb9dd7112145fa88251612f4eb33dd50a32bb5dbf677d873ba36c7420f115c24 - hash

If i use IPFS node for Windows it's broke trying lookup dag cid bafk2bzacec5z3vyrefc7vcbfcyjpj2zt3vikgk5v3p3hpwdtxi3moqqpcfoci, but work to get a file.

Same in console (infinite loop):

ipfs get bafykbzacec5z3vyrefc7vcbfcyjpj2zt3vikgk5v3p3hpwdtxi3moqqpcfoci

If trying make cid with blake2b-256 hex from table.cvs b220, then same problem, infinite loop:

ipfs get bafyleibaxoo5oejbix5iqjiwcl2owm65kcrsxno36z35q452g3duedyrlqsa

https://cid.ipfs.io/#bafyleibaxoo5oejbix5iqjiwcl2owm65kcrsxno36z35q452g3duedyrlqsa Error: multihash unknown function code: 0x1032

On1x commented 2 years ago

If i doing ipfs cid hashes --numeric, its return 45600 blake2b-256, 45600 in hex is b220.

ribasushi commented 2 years ago

@On1x the strucure of CIDv1 is 4 varints + digest: version-varint codec-varint mh-code-varint mh-length-varint mh-digest-bytes

varint here is https://en.wikipedia.org/wiki/LEB128#Unsigned_LEB128 The reason these are used is to avoid needing to specify where each varint starts and ends - the on-wire format is self-describing / self-synchronizing.

0xb220 ( or 45600 ) is the actual mh code value Its varint-encoded form is: https://gchq.github.io/CyberChef/#recipe=VarInt_Encode()To_Hex('Space',0)&input=NDU2MDA