Specifying hash algorithms in files.add doesn't work #1373
Description
Subsystem:
files.add and/or IPLD
Type:
Bug
Severity:
Medium
Description:
jsipfs files add --hash=<alg> ...
generates and stores an incorrect DAG.
The option to specify a different hash alg was added with #1308.
Go/JS ipfs hash differences:
The hashes are both keccak-512
-encoded yet we have different hashes - our object content must be different:
object get <key>
returns a serialized blob that has a hash
different from the one requested. It seems that on unixfs import, IPLD
is generating a blob where the hash
is coerced from the keccak-512
format to something else. I understood dag-pb
to just be a style of serialization and not a hashing function itself so I'm confused what the codec of a CID holding a keccak-512
multihash should be.
@vmx do you have some insight as to what's happening above?
I think the coercion is happening in IPLD/unixfs-engine as unixfs-engine
uses IPLD to generate the DAG tree that unixfs later writes to the fs.
Could it be caused by something like new CID
's assumption that non-CID Buffers are dag-pb
(here). It may also be that IPLD can't yet handle these custom hash functions.