Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Specifying hash algorithms in files.add doesn't work #1373

Closed
@JonKrone

Description

@JonKrone

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:
image
The hashes are both keccak-512-encoded yet we have different hashes - our object content must be different:

image

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.

Metadata

Metadata

Assignees

Labels

P1High: Likely tackled by core team if no one steps upexp/wizardExtensive knowledge (implications, ramifications) required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions