multiformats / multiformats/java-multihash

Support for variable-length hashes

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

Nobody has claimed this yet.

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

Description

Some algorithms (such as SHAKE128) can generate an output of arbitrary length. For example, the following are all valid SHAKE128 hashes of the string hello in UTF-8:

8eb4
8eb4b6a932f28033
8eb4b6a932f280335ee1a279f8c208a3
8eb4b6a932f280335ee1a279f8c208a349e7bc65daf831d302

(generated by the online hash calculator)

In particular, this code should work:

Multihash m = Multihash.fromHex("18028eb4");

Whereas it currently fails with this exception:

java.lang.IllegalStateException: Incorrect hash length: 2 != 32

	at io.ipfs.multihash.Multihash.<init>(Multihash.java:162)
	at io.ipfs.multihash.Multihash.deserialize(Multihash.java:218)
	at io.ipfs.multihash.Multihash.deserialize(Multihash.java:223)
	at io.ipfs.multihash.Multihash.fromHex(Multihash.java:273)

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.

Research direction

Start in Multihash.java at the constructor and deserialize/fromHex call path shown in the stack trace, then reproduce the failure with Multihash.fromHex("18028eb4"). Done means the SHAKE128 example with a 2-byte output is accepted instead of raising the fixed-length exception, while the existing deserialization path continues to work.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.