Skip to content

Commit 8832055

Browse files
authored
Merge branch 'main' into web-redirects-clarifications
2 parents 3d633a6 + 1d52d25 commit 8832055

9 files changed

+13
-665
lines changed

KEYSTORE.md

+2-257
Original file line numberDiff line numberDiff line change
@@ -1,258 +1,3 @@
1-
# ![](https://img.shields.io/badge/status-wip-orange.svg?style=flat-square) Keystore
1+
# Keystore
22

3-
**Authors(s):**
4-
- [whyrusleeping](github.com/whyrusleeping)
5-
- [Hector Sanjuan](github.com/hsanjuan)
6-
7-
* * *
8-
9-
**Abstract**
10-
11-
This spec provides definitions and operations for the keystore feature in IPFS.
12-
13-
# Table of Contents
14-
15-
TODO
16-
17-
## Goals:
18-
19-
To have a secure, simple and user-friendly way of storing and managing keys
20-
for use by ipfs. As well as the ability to share these keys, encrypt, decrypt,
21-
sign and verify data.
22-
23-
## Planned Implementation
24-
25-
### Key storage
26-
27-
Storage layout and format is defined in the [`REPO_FS`](REPO_FS.md) part of the spec.
28-
29-
### Interface
30-
31-
#### ipfs key
32-
33-
```
34-
35-
ipfs key - Interact with ipfs keypairs
36-
37-
SUBCOMMANDS:
38-
39-
ipfs key gen - Generates a new named ipfs keypair
40-
ipfs key list - Lists out all local keypairs
41-
ipfs key info <key> - Get information about a given key
42-
ipfs key rm <key> - Delete a given key from your keystore
43-
ipfs key rename <key> <name> - Renames a given key
44-
ipfs key show <key> - Print out a given key
45-
46-
ipfs key send <key> <peer> - Shares a specified private key with the given peer
47-
48-
Use 'ipfs key <subcmd> --help' for more information about each command.
49-
50-
DESCRIPTION:
51-
52-
'ipfs key' is a command used to manage ipfs keypairs.
53-
54-
```
55-
56-
#### ipfs crypt
57-
58-
```
59-
ipfs crypt - Perform cryptographic operations using ipfs keypairs
60-
61-
SUBCOMMANDS:
62-
63-
ipfs crypt sign <data> - Generates a signature for the given data with a specified key
64-
ipfs crypt verify <data> <sig> - Verify that the given data and signature match
65-
ipfs crypt encrypt <data> - Encrypt the given data
66-
ipfs crypt decrypt <data> - Decrypt the given data
67-
68-
DESCRIPTION:
69-
70-
`ipfs crypt` is a command used to perform various cryptographic operations
71-
using ipfs keypairs, including: signing, verifying, encrypting and decrypting.
72-
```
73-
74-
#### Some subcommands:
75-
76-
##### ipfs key Gen
77-
78-
79-
```
80-
ipfs key gen <name> - Generate a new ipfs keypair
81-
82-
OPTIONS:
83-
-t, -type string - Specify the type and size of key to generate (i.e. rsa)
84-
-s. -size int - Size of the key to generate
85-
-p, -passphrase string - Passphrase for encrypting the private key on disk
86-
87-
DESCRIPTION:
88-
89-
'ipfs key gen' is a command used to generate new keypairs.
90-
```
91-
92-
* * *
93-
94-
##### Key Send
95-
```
96-
97-
ipfs key send <key> <peer> - Send a keypair to a given peer
98-
99-
OPTIONS:
100-
101-
-y, -yes bool - Yes to the prompt
102-
103-
DESCRIPTION:
104-
105-
'ipfs key send' is a command used to share keypairs with other trusted users.
106-
107-
It will first look up the peer specified and print out their information and
108-
prompt the user "are you sure? [y/n]" before sending the keypair. The target
109-
peer must be online and dialable in order for the key to be sent.
110-
111-
Note: while it is still managed through the keystore, ipfs will prevent you from
112-
sharing your nodes private key with anyone else.
113-
114-
```
115-
116-
##### Comments:
117-
118-
Ensure that the user knows the implications of sending a key.
119-
120-
* * *
121-
122-
##### Crypt Encrypt
123-
```
124-
125-
ipfs crypt encrypt <data> - Encrypt the given data with a specified key
126-
127-
ARGUMENTS:
128-
129-
data - The filename of the data to be encrypted ("-" for stdin)
130-
131-
OPTIONS:
132-
133-
-k, -key string - The name of the key to use for encryption (default: localkey)
134-
-o, -output string - The name of the output file (default: stdout)
135-
-c, -cipher string - The cipher to use for the operation
136-
-m, -mode string - The block cipher mode to use for the operation
137-
138-
DESCRIPTION:
139-
140-
'ipfs crypt encrypt' is a command used to encypt data so that only holders of a certain
141-
key can read it.
142-
143-
```
144-
145-
##### Comments:
146-
147-
This should probably just operate on raw data and not on DAGs.
148-
149-
* * *
150-
151-
##### Other Interface Changes
152-
153-
We will also need to make additions to support keys in other commands, these changes are as follows:
154-
155-
- `ipfs add`
156-
- Support for a `-encrypt-key` option, for block encrypting the file being added with the key
157-
- also adds an 'encrypted' node above the root unixfs node
158-
- Support for a `-sign-key` option to attach a signature node above the root unixfs node
159-
160-
- `ipfs block put`
161-
- Support for a `-encrypt-key` option, for encrypting the block before hashing and storing
162-
163-
- `ipfs object put`
164-
- Support for a `-encrypt-key` option, for encrypting the object before hashing and storing
165-
166-
- `ipfs name publish`
167-
- Support for a `-key` option to select which keyspace to publish to
168-
169-
### Code changes and additions
170-
171-
This sections outlines code organization around this feature.
172-
173-
#### Keystore package
174-
175-
The fsrepo carries a `keystore` that can be used to load/store keys. The keystore is implemented following this interface:
176-
177-
```go
178-
// Keystore provides a key management interface
179-
type Keystore interface {
180-
// Has returns whether or not a key exist in the Keystore
181-
Has(string) (bool, error)
182-
// Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists
183-
Put(string, ci.PrivKey) error
184-
// Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey
185-
// otherwise.
186-
Get(string) (ci.PrivKey, error)
187-
// Delete removes a key from the Keystore
188-
Delete(string) error
189-
// List returns a list of key identifier
190-
List() ([]string, error)
191-
}
192-
```
193-
194-
Note: Never store passwords as strings, strings cannot be zeroed out after they are used.
195-
using a byte array allows you to write zeroes over the memory so that the users password
196-
does not linger in memory.
197-
198-
#### Unixfs
199-
200-
- new node types, 'encrypted' and 'signed', probably shouldn't be in unixfs, just understood by it
201-
- if new node types are not unixfs nodes, special consideration must be given to the interop
202-
203-
- DagReader needs to be able to access keystore to seamlessly stream encrypted data we have keys for
204-
- also needs to be able to verify signatures
205-
206-
#### Importer
207-
208-
- DagBuilderHelper needs to be able to encrypt blocks
209-
- Dag Nodes should be generated like normal, then encrypted, and their parents should
210-
link to the hash of the encrypted node
211-
- DagBuilderParams should have extra parameters to accommodate creating a DBH that encrypts the blocks
212-
213-
#### New 'Encrypt' package
214-
215-
Should contain code for crypto operations on dags.
216-
217-
Encryption of dags should work by first generating a symmetric key, and using
218-
that key to encrypt all the data. That key should then be encrypted with the
219-
public key chosen and stored in the Encrypted DAG structure.
220-
221-
Note: One option is to simply add it to the key interface.
222-
223-
### Structures
224-
Some tentative mockups (in json) of the new DAG structures for signing and encrypting
225-
226-
Signed DAG:
227-
```
228-
{
229-
"Links" : [
230-
{
231-
"Name":"@content",
232-
"Hash":"QmTheContent",
233-
}
234-
],
235-
"Data": protobuf{
236-
"Type":"Signed DAG",
237-
"Signature": "thesignature",
238-
"PubKeyID": "QmPubKeyHash",
239-
}
240-
}
241-
```
242-
243-
Encrypted DAG:
244-
```
245-
{
246-
"Links" : [
247-
{
248-
"Name":"@content",
249-
"Hash":"QmRawEncryptedDag",
250-
}
251-
],
252-
"Data": protobuf{
253-
"Type":"Encrypted DAG",
254-
"PubKeyID": "QmPubKeyHash",
255-
"Key": "ephemeral symmetric key, encrypted with public key",
256-
}
257-
}
258-
```
3+
Moved to https://github.com/ipfs/kubo/blob/master/docs/specifications/keystore.md

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SPEC_GENERATOR_VER=1.3.2
1+
SPEC_GENERATOR_VER=1.4.0
22

33
.PHONY: install
44

REPO.md

+2-127
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,3 @@
1-
# ![](https://img.shields.io/badge/status-wip-orange.svg?style=flat-square) IPFS Repo Spec
1+
# Repository
22

3-
**Author(s)**:
4-
- [Juan Benet](github.com/jbenet)
5-
6-
* * *
7-
8-
**Abstract**
9-
10-
This spec defines an IPFS Repo, its contents, and its interface. It does not specify how the repo data is actually stored, as that is done via swappable implementations.
11-
12-
# Table of Contents
13-
14-
TODO
15-
16-
## Definition
17-
18-
A `repo` is the storage repository of an IPFS node. It is the subsystem that
19-
actually stores the data IPFS nodes use. All IPFS objects are stored
20-
in a repo (similar to git).
21-
22-
There are many possible repo implementations, depending on the storage media
23-
used. Most commonly, IPFS nodes use an [fs-repo](REPO_FS.md).
24-
25-
Repo Implementations:
26-
- [fs-repo](REPO_FS.md) - stored in the os filesystem
27-
- mem-repo - stored in process memory
28-
- s3-repo - stored in amazon s3
29-
30-
<center>
31-
<img src="img/ipfs-repo.png" width="256" />
32-
</center>
33-
34-
## Repo Contents
35-
36-
The Repo stores a collection of [IPLD](https://github.com/ipld/specs#readme) objects that represent:
37-
38-
- **config** - node configuration and settings
39-
- **datastore** - content stored locally, and indexing data
40-
- **keystore** - cryptographic keys, including node's identity
41-
- **hooks** - scripts to run at predefined times (not yet implemented)
42-
43-
Note that the IPLD objects a repo stores are divided into:
44-
- **state** (system, control plane) used for the node's internal state
45-
- **content** (userland, data plane) which represent the user's cached and pinned data.
46-
47-
Additionally, the repo state must determine the following. These need not be IPLD objects, though it is of course encouraged:
48-
49-
- **version** - the repo version, required for safe migrations
50-
- **locks** - process semaphores for correct concurrent access
51-
- **datastore_spec** - array of mounting points and their properties
52-
53-
Finally, the repo also stores the blocks with blobs containing binary data.
54-
55-
![](/img/ipfs-repo-contents.png)
56-
57-
### version
58-
59-
Repo implementations may change over time, thus they MUST include a `version` recognizable across versions. Meaning that a tool MUST be able to read the `version` of a given repo type.
60-
61-
For example, the `fs-repo` simply includes a `version` file with the version number. This way, the repo contents can evolve over time but the version remains readable the same way across versions.
62-
63-
### datastore
64-
65-
IPFS nodes store some IPLD objects locally. These are either (a) **state objects** required for local operation -- such as the `config` and `keys` -- or (b) **content objects** used to represent data locally available. **Content objects** are either _pinned_ (stored until they are unpinned) or _cached_ (stored until the next repo garbage collection).
66-
67-
The name "datastore" comes from [go-datastore](https://github.com/jbenet/go-datastore), a library for swappable key-value stores. Like its name-sake, some repo implementations feature swappable datastores, for example:
68-
- an fs-repo with a leveldb datastore
69-
- an fs-repo with a boltdb datastore
70-
- an fs-repo with a union fs and leveldb datastore
71-
- an fs-repo with an s3 datastore
72-
- an s3-repo with a cached fs and s3 datastore
73-
74-
This makes it easy to change properties or performance characteristics of a repo without an entirely new implementation.
75-
76-
### keystore
77-
78-
A Repo typically holds the keys a node has access to, for signing and for encryption.
79-
80-
Details on operation and storage of the keystore can be found in [`REPO_FS.md`](REPO_FS.md) and [`KEYSTORE.md`](KEYSTORE.md).
81-
82-
### config (state)
83-
84-
The node's `config` (configuration) is a tree of variables, used to configure various aspects of operation. For example:
85-
- the set of bootstrap peers IPFS uses to connect to the network
86-
- the Swarm, API, and Gateway network listen addresses
87-
- the Datastore configuration regarding the construction and operation of the on-disk storage system.
88-
89-
There is a set of properties, which are mandatory for the repo usage. Those are `Addresses`, `Discovery`, `Bootstrap`, `Identity`, `Datastore` and `Keychain`.
90-
91-
It is recommended that `config` files avoid identifying information, so that they may be re-shared across multiple nodes.
92-
93-
**CHANGES**: today, implementations like js-ipfs and go-ipfs store the peer-id and private key directly in the config. These will be removed and moved out.
94-
95-
### locks
96-
97-
IPFS implementations may use multiple processes, or may disallow multiple processes from using the same repo simultaneously. Others may disallow using the same repo but may allow sharing _datastores_ simultaneously. This synchronization is accomplished via _locks_.
98-
99-
All repos contain the following standard locks:
100-
- `repo.lock` - prevents concurrent access to the repo. Must be held to _read_ or _write_.
101-
102-
### datastore_spec
103-
104-
This file is created according to the Datastore configuration specified in the `config` file. It contains an array with all the mounting points that the repo is using, as well as its properties. This way, the `datastore_spec` file must have the same mounting points as defined in the Datastore configuration.
105-
106-
It is important pointing out that the `Datastore` in config must have a `Spec` property, which defines the structure of the ipfs datastore. It is a composable structure, where each datastore is represented by a json object.
107-
108-
### hooks (TODO)
109-
110-
Like git, IPFS nodes will allow `hooks`, a set of user configurable scripts to run at predefined moments in IPFS operations. This makes it easy to customize the behavior of IPFS nodes without changing the implementations themselves.
111-
112-
## Notes
113-
114-
#### A Repo uniquely identifies an IPFS Node
115-
116-
A repository uniquely identifies a node. Running two different IPFS programs with identical repositories -- and thus identical identities -- WILL cause problems.
117-
118-
Datastores MAY be shared -- with proper synchronization -- though note that sharing datastore access MAY erode privacy.
119-
120-
#### Repo implementation changes MUST include migrations
121-
122-
**DO NOT BREAK USERS' DATA.** This is critical. Thus, any changes to a repo's implementation **MUST** be accompanied by a **SAFE** migration tool.
123-
124-
See https://github.com/jbenet/go-ipfs/issues/537 and https://github.com/jbenet/random-ideas/issues/33
125-
126-
#### Repo Versioning
127-
128-
A repo version is a single incrementing integer. All versions are considered non-compatible. Repos of different versions MUST be run through the appropriate migration tools before use.
3+
Moved to https://github.com/ipfs/kubo/blob/master/docs/specifications/repository.md

0 commit comments

Comments
 (0)