diff --git a/proposals/js-libp2p-bundle.png b/proposals/js-libp2p-bundle.png new file mode 100644 index 00000000..38f03c80 Binary files /dev/null and b/proposals/js-libp2p-bundle.png differ diff --git a/proposals/large-crypto-blobs.md b/proposals/large-crypto-blobs.md new file mode 100644 index 00000000..573cb5af --- /dev/null +++ b/proposals/large-crypto-blobs.md @@ -0,0 +1,142 @@ +# JS modular crypto + +Authors: @vasco-santos + +Initial PR: https://github.com/protocol/web3-dev-team/pull/71 + + + + + +## Purpose & impact +#### Background & intent +_Describe the desired state of the world after this project? Why does that matter?_ + + +One of the pain points of development within a browser context is the bundle size of a web app, which easily gets quite big and makes web apps to take longer times loading. + +In `js-libp2p` and `js-ipfs`, we have been working towards reducing the bundle size of the library to the minimum possible, so that the users of our stack don't need to ship gigantic bundle size applications just for using parts of our stack. However, we also created technical debt when `libp2p-noise` was added to the stack, as a new crypto library was added. + +One of the outstanding issues to have our bundle size in a considerably good shape is the crypto libraries that we need to carry. The JS ecosystem around cryptography is far from perfect, which has made us rely on several different libraries to achieve different cryptographic primitives. + +![image info](./js-libp2p-bundle.png) + +The current bundle size for libp2p gzipped is 222.63KB. From the image above we can see that `node-forge`, `elliptic`, `libp2p-crypto`, `hash.js` and `blakejs` consist of around half of our shipped bundle. + +Taking into account that libp2p is a composable and modular stack, most of the times `js-libp2p` bundle contains heavy crypto code that is not needed. In this context, `js-libp2p` crypto should be modular and pluggable, so that the users can bring just what they need instead of the all thing. + +This has been a pain for some users, including team spark did not rely on libp2p for NFT project because it was too heavy. This can be a threat for the wide usage of libp2p in the web3 ecosystem. + +#### Assumptions & hypotheses +_What must be true for this project to matter?_ + + +- Web3 users want to create libp2p backed applications with only the code they use bundled +- Web3 users want to provide smooth and fast experiences to their users +- Web3 users do not want to have their apps taking X seconds to load + +#### User workflow example +_How would a developer or user use this new capability?_ + + +- Users can configure via libp2p configuration what cryptographic modules they are interested in using +- Libp2p provides custom bundles for the most common use cases that users can rely on (out of the box usage) + +#### Impact +_How would this directly contribute to web3 dev stack product-market fit?_ + + + +#### Leverage +_How much would nailing this project improve our knowledge and ability to execute future projects?_ + + + +#### Confidence +_How sure are we that this impact would be realized? Label from [this scale](https://medium.com/@nimay/inside-product-introduction-to-feature-priority-using-ice-impact-confidence-ease-and-gist-5180434e5b15)_. + + + + +## Project definition +#### Brief plan of attack + + + +1. Create crypto interface definition (inspiration from prior art in `js-multiformats`) +2. Use [stablelib](https://github.com/StableLib/stablelib) as the source of all the crypto items needed + - `libp2p-crypto` turned into a libp2p spec compliant api on top of that +3. New `libp2p-crypto` is integrated with all libp2p modules and core + +#### What does done look like? +_What specific deliverables should completed to consider this project done?_ + +- Libp2p can be configured according to the cryptographic needs +- Libp2p provides ready to go bundles for typical use cases +- A minimal libp2p node can be configured with a maximum of 150Kb (?). + +#### What does success look like? +_Success means impact. How will we know we did the right thing?_ + + + +- libp2p and IPFS based web applications load time is not bigger than a regular web application + +#### Counterpoints & pre-mortem +_Why might this project be lower impact than expected? How could this project fail to complete, or fail to be successful?_ + +#### Alternatives +_How might this project’s intent be realized in other ways (other than this project proposal)? What other potential solutions can address the same need?_ + +- Reuse parts of [rust-libp2p](https://github.com/libp2p/rust-libp2p) compiled for WASM backend. + - Look into other WASM alternative +- Work with partners (e.g. Igalia) to drive crypto implementation and landing efforts in browsers natively. + +#### Dependencies/prerequisites + + +#### Future opportunities + + +## Required resources + +#### Effort estimate + + +Medium + +Uncertainty in the scope until design work and crypto changes are always challenging + +#### Roles / skills needed + + +- js-libp2p expertise +- cryptography expertise