Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
private-network RFC#67
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
30c0c0b
rewrite private-network RFC
farhoud d5e3598
Update docs/RFCs/private-network.md
farhoud 44ac8d5
Update docs/RFCs/private-network.md
farhoud 10de984
Update docs/RFCs/private-network.md
farhoud 041a0b7
Update docs/RFCs/private-network.md
farhoud d0acb97
Update docs/RFCs/private-network.md
farhoud bd04dcd
Update docs/RFCs/private-network.md
farhoud 683b3d5
Update docs/RFCs/private-network.md
farhoud 48e2e09
second draft
farhoud 10225f9
Add more details on implementation and case study
farhoud 7bc9efd
fix indent.
farhoud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| - Feature Name: private-network | ||
| - Start Date: 2022-02-01 | ||
| - RFC PR: https://github.com/functionland/docs/pull/67 | ||
| - Functionland Issue: https://github.com/functionland/docs/issues/63 | ||
| ## Background | ||
| We are using IPFS as our file system. But IPFS is built to use for public data, and it does not support ACL, | ||
| So we need to find a way to keep users safe until our security layer becomes mature. And also ipfs-cluster [docs](https://cluster.ipfs.io/documentation/guides/security/#ports-overview) recommended to have a secret. | ||
| ###Current Network | ||
| Our current network topology is too simple, its only base on webrtc-start and peer discovery is disabled. | ||
| #### Server | ||
| Node with roll of server is a js-libp2p node with our protocol's and server side implementations (use js-ipfs as fs) that listen on [webrtc-start](https://github.com/functionland/fula/blob/main/libraries/fula-client/src/config.ts). | ||
| #### Client | ||
| Node with the roll of [client](https://github.com/functionland/fula/tree/main/libraries/fula-client) (phone,webapp) are listening on [webrtc-start](https://github.com/functionland/fula/blob/main/libraries/fula-client/src/config.ts) and when user provide the string peer id (`B58String`) of the box with [connect](https://docs.fx.land/api/client-instance#connect-to-box) API, the api create multiAddress based on webrtc signaling server add it to libp2p peer store and keep the connection alive with the box. | ||
| also have to mention inbound connections are blocked. | ||
| ## Problem Statement | ||
| We need to protect users and their data from harms and risks of public networks and also cover the [multi box scenario](https://github.com/functionland/docs/issues/58). | ||
| The public network risks are: | ||
| - Anyone on the internet can connect to the box. | ||
| - Anyone on the internet that is connected to the box can use bitswap to get data from the box. | ||
| - Peer routing and Content discovery can leak what you are doing to the public. | ||
| - deficiency in our encryption algorithm or key management can leak all user data to the public. | ||
| - clusters running without a secret may discover and connect to the main IPFS network, which is mostly useless for the cluster peers (and for the IPFS network). | ||
| ## Motivation | ||
| Isolating users from public networks can help us reduce the scope of work while maintaining the usefulness of our product, and testing our security layer without putting users in harm's way. | ||
| ## Proposal | ||
| We can use built-in libp2p components to create a private network with encrypted communication. | ||
| The components are: | ||
| - Libp2p built-in private network. It uses a [private shared key](https://github.com/libp2p/js-libp2p/tree/master/src/pnet#private-shared-keys) for creating an isolated network with encrypted communication. | ||
| - [spec](https://github.com/libp2p/specs/blob/master/pnet/Private-Networks-PSK-V1.md) | ||
| - [js-doc](https://github.com/libp2p/js-libp2p/tree/master/src/pnet) | ||
| - Libp2p bootstrap for bootstrapping the network of boxes: | ||
| - [js-doc](https://github.com/libp2p/js-libp2p-bootstrap) | ||
| In this way when a node comes online, Libp2p uses the key and the list of other node's to join the network. | ||
| ## Scope of work | ||
| ### Box | ||
| For box setup users provide an environment variable `FULA_NET_SECRET` which they should remember. and provide a list of node as `config.json` | ||
| ### FULA-Client | ||
| user calls `createClient` they should also provide the secret they used for setting up the boxes. and when he calls `connect` it should pass the list of string peerId's | ||
| ## Implementation | ||
| The box and client already support private-key but need to add test and fixes namings. | ||
| ### Box | ||
| In the [Config](https://github.com/functionland/fula/blob/main/apps/box/src/config.ts) we should change the name `PKEY` to `FULA_NET_SECRET` | ||
| We need to add [`js-libp2p-bootstrap`](https://github.com/libp2p/js-libp2p-bootstrap) and | ||
| In the [Config](https://github.com/functionland/fula/blob/main/apps/box/src/config.ts) we should add to support to load `config.json` in this format: | ||
| ```json | ||
| { | ||
| "nodes": [ | ||
| "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", | ||
| "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", | ||
| "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa" | ||
| ] | ||
| } | ||
| ``` | ||
| Which will be used for creating `js-libp2p-bootstrap` [config](https://github.com/libp2p/js-libp2p-bootstrap). | ||
| ### FULA-client | ||
| In [fula-client](https://github.com/functionland/fula/blob/main/libraries/fula-client/src/index.ts) We have to change pkey to fulaSecret so: | ||
| ```ts | ||
| createClient(config?: Partial<Libp2pOptions & constructorOptions>, pKey = undefined): Promise<Fula> | ||
| ``` | ||
| to | ||
| ```ts | ||
| createClient(config?: Partial<Libp2pOptions & constructorOptions>, fulaSecret = undefined): Promise<Fula> | ||
| ``` | ||
| and change connect interface to get a list of peerId`s from: | ||
| ``` | ||
| connect: (peerId: string) => Connection | ||
| ``` | ||
| to | ||
| ``` | ||
| connect: (peerId: [string]) => Connection | ||
| ``` | ||
| We need to change [`Connection`](https://github.com/functionland/fula/blob/main/libraries/fula-client/src/connection.ts) in the way that: | ||
| - Connection `Status` | ||
| - If we connect to at least one box we are `Online`. | ||
| - When we are not connected to any box and try to connect we are at `Connecting`. | ||
| - When connection fails to all the serverPeerIds we Are `Offline`. | ||
| - Connection should have a list of `serverPeerId`. | ||
| - Connect to all the `serverPeerId` and keep the connection alive. | ||
| ## Case Study | ||
| For dogfooding of new changes we can use a copy of [react-gallery](https://github.com/functionland/fula/tree/main/examples/react-gallery) and change | ||
| the [`BoxConfig`](https://github.com/functionland/fula/blob/main/examples/react-gallery/src/components/BoxConfig.jsx) | ||
| to get list of comma seperated peerIds and [`App`](https://github.com/functionland/fula/blob/main/examples/react-gallery/src/App.js) should change to pass the list of peerId's to fula-client. | ||
| Note: if example repo would be outside mono-repo we can just use branch for describing every functionality. | ||
| ## Alternative approaches | ||
| ### VPN | ||
| Using VPN for creating the private network. | ||
| Disadvantage: | ||
| - It adds another point of failure to the system. | ||
| - It is also not that decentralized. | ||
| ## Risks | ||
| ### Work prioritization | ||
| ### Anything that impacts the value of RFC | ||
| ### What could impact delivery of this RFC? | ||
| ## Dependencies | ||
| ## Impact | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to talk about how the network is joined together. So far this reads as a simple key generation RFC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to add current network topology to background and also how network join in the proposal