|
1 |
| -#  Keystore |
| 1 | +# Keystore |
2 | 2 |
|
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 |
0 commit comments