Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

DAG API example is wrong #307

Closed
richardschneider opened this issue Jun 21, 2018 · 5 comments
Closed

DAG API example is wrong #307

richardschneider opened this issue Jun 21, 2018 · 5 comments

Comments

@richardschneider
Copy link
Contributor

The dag.put example in https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md is wrong.

const obj = { simple: 'object' }
ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => {
    console.log(cid.toBaseEncodedString())
   // zdpuAzE1oAAMpsfdoexcJv6PmL9UhE8nddUYGU32R98tzV5fv
})

The expected cid of zdpuAzE1oAAMpsfdoexcJv6PmL9UhE8nddUYGU32R98tzV5fv decodes as base58btc cidv1 dag-cbor sha2-256 Qmc9E2LoddF1MdSVzYaaFxr6iByWSa2Q7pSpiKHcV4drm6.

The hash algorithm should be sha3-512 not sha2-256.

@richardschneider
Copy link
Contributor Author

This is related to ipld/js-ipld#82

@alanshaw
Copy link
Contributor

alanshaw commented Aug 7, 2018

@PascalPrecht any chance you can send a PR to fix this up? 😉 🙏

@alanshaw alanshaw added the ready label Aug 7, 2018
@0x-r4bbit
Copy link
Contributor

On my way!

@0x-r4bbit
Copy link
Contributor

The hash algorithm should be sha3-512 not sha2-256.

Well actually, the algorithm is right, but the hash should be different. I guess the example should demonstrate how to override the default hash algorithm (which is already sha-256). I'll send a PR to update the hash

0x-r4bbit added a commit to 0x-r4bbit/interface-ipfs-core that referenced this issue Aug 7, 2018
Closes ipfs-inactive#307

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@0x-r4bbit
Copy link
Contributor

alanshaw pushed a commit that referenced this issue Aug 7, 2018
…347)

Closes #307

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@ghost ghost removed the ready label Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants