@libp2p/keychain 3.0.6-d5ef1c91 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -35
- package/dist/index.min.js +7 -7
- package/dist/src/index.d.ts +51 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +51 -0
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +10 -0
- package/package.json +6 -6
- package/src/index.ts +52 -0
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# @libp2p/keychain <!-- omit in toc -->
|
|
2
|
-
|
|
3
1
|
[](http://libp2p.io/)
|
|
4
2
|
[](https://discuss.libp2p.io)
|
|
5
3
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,33 +5,7 @@
|
|
|
7
5
|
|
|
8
6
|
> Key management and cryptographically protected messages
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
|
-
- [Features](#features)
|
|
15
|
-
- [KeyInfo](#keyinfo)
|
|
16
|
-
- [Private key storage](#private-key-storage)
|
|
17
|
-
- [Physical storage](#physical-storage)
|
|
18
|
-
- [API Docs](#api-docs)
|
|
19
|
-
- [License](#license)
|
|
20
|
-
- [Contribution](#contribution)
|
|
21
|
-
|
|
22
|
-
## Install
|
|
23
|
-
|
|
24
|
-
```console
|
|
25
|
-
$ npm i @libp2p/keychain
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Browser `<script>` tag
|
|
29
|
-
|
|
30
|
-
Loading this module through a script tag will make it's exports available as `Libp2pKeychain` in the global namespace.
|
|
31
|
-
|
|
32
|
-
```html
|
|
33
|
-
<script src="https://unpkg.com/@libp2p/keychain/dist/index.min.js"></script>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Features
|
|
8
|
+
# About
|
|
37
9
|
|
|
38
10
|
- Manages the lifecycle of a key
|
|
39
11
|
- Keys are encrypted at rest
|
|
@@ -43,7 +15,7 @@ Loading this module through a script tag will make it's exports available as `Li
|
|
|
43
15
|
- Enforces NIST SP 800-131A and NIST SP 800-132
|
|
44
16
|
- Delays reporting errors to slow down brute force attacks
|
|
45
17
|
|
|
46
|
-
|
|
18
|
+
## KeyInfo
|
|
47
19
|
|
|
48
20
|
The key management and naming service API all return a `KeyInfo` object. The `id` is a universally unique identifier for the key. The `name` is local to the key chain.
|
|
49
21
|
|
|
@@ -54,9 +26,11 @@ The key management and naming service API all return a `KeyInfo` object. The `i
|
|
|
54
26
|
}
|
|
55
27
|
```
|
|
56
28
|
|
|
57
|
-
The **key id** is the SHA-256 [multihash](https://github.com/multiformats/multihash) of its public key.
|
|
29
|
+
The **key id** is the SHA-256 [multihash](https://github.com/multiformats/multihash) of its public key.
|
|
58
30
|
|
|
59
|
-
|
|
31
|
+
The *public key* is a [protobuf encoding](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/keys.proto.js) containing a type and the [DER encoding](https://en.wikipedia.org/wiki/X.690) of the PKCS [SubjectPublicKeyInfo](https://www.ietf.org/rfc/rfc3279.txt).
|
|
32
|
+
|
|
33
|
+
## Private key storage
|
|
60
34
|
|
|
61
35
|
A private key is stored as an encrypted PKCS 8 structure in the PEM format. It is protected by a key generated from the key chain's *passPhrase* using **PBKDF2**.
|
|
62
36
|
|
|
@@ -64,7 +38,7 @@ The default options for generating the derived encryption key are in the `dek` o
|
|
|
64
38
|
|
|
65
39
|
```js
|
|
66
40
|
const defaultOptions = {
|
|
67
|
-
|
|
41
|
+
// See https://cryptosense.com/parameter-choice-for-pbkdf2/
|
|
68
42
|
dek: {
|
|
69
43
|
keyLength: 512 / 8,
|
|
70
44
|
iterationCount: 1000,
|
|
@@ -76,9 +50,25 @@ const defaultOptions = {
|
|
|
76
50
|
|
|
77
51
|

|
|
78
52
|
|
|
79
|
-
|
|
53
|
+
## Physical storage
|
|
54
|
+
|
|
55
|
+
The actual physical storage of an encrypted key is left to implementations of [interface-datastore](https://github.com/ipfs/interface-datastore/).
|
|
56
|
+
|
|
57
|
+
A key benefit is that now the key chain can be used in browser with the [js-datastore-level](https://github.com/ipfs/js-datastore-level) implementation.
|
|
58
|
+
|
|
59
|
+
# Install
|
|
60
|
+
|
|
61
|
+
```console
|
|
62
|
+
$ npm i @libp2p/keychain
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Browser `<script>` tag
|
|
66
|
+
|
|
67
|
+
Loading this module through a script tag will make it's exports available as `Libp2pKeychain` in the global namespace.
|
|
80
68
|
|
|
81
|
-
|
|
69
|
+
```html
|
|
70
|
+
<script src="https://unpkg.com/@libp2p/keychain/dist/index.min.js"></script>
|
|
71
|
+
```
|
|
82
72
|
|
|
83
73
|
## API Docs
|
|
84
74
|
|