Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for variable-length hashes #45

Open
odisseus opened this issue Jan 7, 2025 · 0 comments · May be fixed by #46
Open

Support for variable-length hashes #45

odisseus opened this issue Jan 7, 2025 · 0 comments · May be fixed by #46

Comments

@odisseus
Copy link
Contributor

odisseus commented Jan 7, 2025

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant