multiformats / multiformats/js-multiformats
Proposal: StreamMultihasher interface
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 268
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
Rational
Current MultihashHasher API is really simple and a great fit for most cases, however it has certain drawbacks that make it a bad fit for more low-level use cases.
- API returns a
Digestview for which you always have to allocate a buffer. If you have destination buffer for the multihash like a CAR or even a CID it creates unnecessary overhead of first allocating then copying the bytes into your destination.- It is also worth calling out that web crypto APIs require you to pass a ArrayBufferView.
- API assumes that you can hold complete payload in memory. When working on a large payloads this becomes a real problem. Unfortunately currently browsers do not provide streaming crypto APIs, but there seems to be some proposals to address this, never the less it would still be good to have it in node and non web native implementations.
- Sometimes you need a digest without the multiformat prefix and addressing above two without a way to omit the prefix would defeat the purpose in those instances.
Proposal
I end up defining separate interface to address above limitations and implemented two hashers that makes use of it
I propose we uplift interface used by those implementations, possibly after iterating on it a bit here. I'm happy to update those implementations to align with interface that gets merged here.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current MultihashHasher API, then compare the proposed interface with the blake3-multihash implementation in src/lib.js and the referenced data-segment pull request. Done means reaching agreement on an uplifted streaming hasher interface that addresses buffer destinations, streaming payloads, and optional multiformat prefixes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100