-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Specifying hash algorithms in files.add doesn't work #1373
Comments
I think @achingbrain is all over this with #1371 - @JonKrone can you verify if this PR fixes your issues? |
I just realised that PR doesn't actually change any dependencies, we might need to wait for the dependent PRs to be merged. |
@alanshaw cool, thanks for bringing that to my attention! That might resolve the bit about go/js having different hashes. I think we will still be generating an incorrect DAG. |
IPLD doesn't support custom hash functions: https://github.com/ipld/js-ipld/blob/a6329ce30e4b21bb2d0852326cfd55753c33b353/src/index.js#L239 |
@JonKrone I'd be surprised if it would work. |
@alanshaw As this feature is broken and has a more involved fix with no timeline, I think it should be reverted or we should otherwise indicate that it's not ready for use. |
@JonKrone I believe this is now resolved - #1371 was merged and IPLD now supports specifying the hash algorithm ipld/js-ipld#133 Are you able to double check? |
Hey @alanshaw! I was excited when I saw this but after fresh installs of the most recent go and js versions, I still see mismatched hashes for the |
@JonKrone which version are you using? I see CIDv1 with $ jsipfs add foo.txt --hash=keccak-512
added zBurK9v3LNabF2nosKPjnPWznRAQRjAEuRLx2Mbsa2qVtrYRA48dYybAXUGsXUhB1KQipPnYie1mQmnnxYik1DHThzReM foo.txt
$ jsipfs --version
0.31.1 |
@achingbrain Yep! And that part works! What seems to fail is:
I think the part of the add stream where this happens is when I'm using |
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 ahash
different from the one requested. It seems that on unixfs import,IPLD
is generating a blob where thehash
is coerced from thekeccak-512
format to something else. I understooddag-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 akeccak-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 aredag-pb
(here). It may also be that IPLD can't yet handle these custom hash functions.The text was updated successfully, but these errors were encountered: