Add blake3 support

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
cryptography

Research direction

Start with Multihash.Type.lookup and Multihash.deserialize, then follow the failure through Cid.cast, Cid.decode, and MerkleNode.fromJSON. Verify the AddArgs example using blake3 no longer raises the unknown multihash type exception and that the resulting CID is accepted.

Written by the indexing model from the issue text.

Description

var args = AddArgs.Builder.newInstance().setCidVersion(1).setHash("blake3").build();
ipfs.add(namedStreamable, args);

causes:

Invalid cid bytes: 01551e20623a5460d841b6d1c13d080e85500e0043fd4ba4a8ba9c1aa9b4f6e0d212276c
io.ipfs.cid.Cid$CidEncodingException: 
	at io.ipfs.cid.Cid.cast(Cid.java:188)
	at io.ipfs.cid.Cid.decode(Cid.java:168)
	at io.ipfs.api.MerkleNode.<init>(MerkleNode.java:27)
	at io.ipfs.api.MerkleNode.fromJSON(MerkleNode.java:85)
	at io.ipfs.api.IPFS.lambda$add$1(IPFS.java:161)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at io.ipfs.api.IPFS.add(IPFS.java:162)
	at io.ipfs.api.IPFS.add(IPFS.java:148)
	at dev.enola.cas.IPFSBlobStore.store(IPFSBlobStore.java:53)
	at dev.enola.cas.IPFSBlobStoreTest.storeHello(IPFSBlobStoreTest.java:61)
Caused by: java.lang.IllegalStateException: Unknown Multihash type: 0x1e
	at io.ipfs.multihash.Multihash$Type.lookup(Multihash.java:147)
	at io.ipfs.multihash.Multihash.deserialize(Multihash.java:208)
	at io.ipfs.cid.Cid.cast(Cid.java:182)

I'll raise a PR once my other older pending PRs have been reviewed and merged... 😆

Dominant language
Java
Stars
53
Forks
28
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from multiformats/java-multihash

All issues in multiformats/java-multihash

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.