hyper-multisig 0.1.2 → 1.0.0
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 +106 -47
- package/index.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,75 +2,134 @@
|
|
|
2
2
|
|
|
3
3
|
# Hyper Multisig
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Create signing requests for multisig cores and drives
|
|
7
|
-
- Sign and release multisig cores and drives
|
|
5
|
+
Create and manage multisig hypercores and hyperdrives.
|
|
8
6
|
|
|
9
|
-
Includes sanity checks to avoid common mistakes and risky releases (detecting conflicts before committing, ensuring all cores are seeded by multiple
|
|
7
|
+
Includes sanity checks to avoid common mistakes and risky releases (detecting conflicts before committing, ensuring all cores are seeded by multiple peers, etc.)
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
End users most likely want to use [hyper-multisig-cli](https://github.com/holepunchto/hyper-multisig-cli) instead of interacting directly with this module.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
npm
|
|
14
|
+
npm install -g hyper-multisig
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## API
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
#### `const multisig = new HyperMultisig(store, swarm)`
|
|
20
|
+
|
|
21
|
+
Create a new HyperMultisig instance.
|
|
22
|
+
|
|
23
|
+
- `store` - a [Corestore](https://github.com/holepunchto/corestore) instance
|
|
24
|
+
- `swarm` - a [Hyperswarm](https://github.com/holepunchto/hyperswarm) instance
|
|
25
|
+
|
|
26
|
+
#### `const { manifest, key, core } = await multisig.createCore(publicKeys, namespace, [options])`
|
|
27
|
+
|
|
28
|
+
Create a multisig hypercore.
|
|
29
|
+
|
|
30
|
+
- `publicKeys` - array of z32-encoded public keys from all signers
|
|
31
|
+
- `namespace` - string to avoid collisions (the combination of signers and namespace must be globally unique, as it deterministically defines the key of the resulting multisig hypercore)
|
|
32
|
+
|
|
33
|
+
Options include:
|
|
34
|
+
|
|
35
|
+
- quorum: minimum number of signatures required, defaults to half of public keys + 1
|
|
36
|
+
|
|
37
|
+
Returns `{ manifest, key, core }` where `core` is a read-only Hypercore.
|
|
38
|
+
|
|
39
|
+
#### `const { manifest, key, core, blobsManifest, blobsKey, blobsCore } = await multisig.createDrive(publicKeys, namespace, [options])`
|
|
40
|
+
|
|
41
|
+
Create a multisig hyperdrive (with associated blobs core).
|
|
42
|
+
|
|
43
|
+
Same parameters and options as `createCore`.
|
|
44
|
+
|
|
45
|
+
#### `const runner = multisig.requestCore(publicKeys, namespace, srcCore, length, [options])`
|
|
20
46
|
|
|
21
|
-
|
|
47
|
+
Generate a signing request from a source core.
|
|
48
|
+
|
|
49
|
+
- `publicKeys` - array of public keys
|
|
50
|
+
- `namespace` - namespace string
|
|
51
|
+
- `srcCore` - source Hypercore to create a request for
|
|
52
|
+
- `length` - length of the source core to use for the request
|
|
53
|
+
|
|
54
|
+
Options include:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
{
|
|
58
|
+
force: false, // skip verification checks
|
|
59
|
+
quorum, // override default quorum
|
|
60
|
+
peerUpdateTimeout: 5000 // timeout in ms for peer updates
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Call `await runner.done()` to get `{ manifest, request }`. The `request` is the signing request, as a buffer.
|
|
65
|
+
|
|
66
|
+
#### `const runner = multisig.requestDrive(publicKeys, namespace, srcDrive, length, [options])`
|
|
67
|
+
|
|
68
|
+
Generate a signing request for a source drive.
|
|
69
|
+
|
|
70
|
+
Same parameters and options as `requestCore`, but takes a Hyperdrive instead of a Hypercore.
|
|
71
|
+
|
|
72
|
+
Call `await runner.done()` to get `{ manifest, request }`.
|
|
73
|
+
|
|
74
|
+
#### `const runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, [options])`
|
|
75
|
+
|
|
76
|
+
Commit signed data to a multisig core.
|
|
77
|
+
|
|
78
|
+
- `publicKeys` - array of public keys
|
|
79
|
+
- `namespace` - namespace string
|
|
80
|
+
- `srcCore` - source Hypercore that was signed
|
|
81
|
+
- `request` - the signing request
|
|
82
|
+
- `responses` - array of signed responses from signers
|
|
83
|
+
|
|
84
|
+
Options include:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
{
|
|
88
|
+
quorum, // override default quorum
|
|
89
|
+
dryRun: false, // perform validation without committing
|
|
90
|
+
force: false, // advanced option, and dangerous
|
|
91
|
+
skipTargetChecks: false, // only useful for the first commit
|
|
92
|
+
peerUpdateTimeout: 5000, // timeout in ms for peer updates
|
|
93
|
+
minFullCopies: 2 // minimum number of peers with a full copy of the core
|
|
94
|
+
}
|
|
95
|
+
```
|
|
22
96
|
|
|
23
|
-
|
|
97
|
+
Call `await runner.done()` to get `{ manifest, core, quorum, result }` where `quorum` is the amount of valid signatures.
|
|
24
98
|
|
|
25
|
-
|
|
26
|
-
hypercore-sign generate-keys
|
|
99
|
+
The runner emits events during the commit process:
|
|
27
100
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
101
|
+
- `'verify-committable-start'` - fired with `(srcCoreKey, destCoreKey)`
|
|
102
|
+
- `'commit-start'` - fired when the commit begins
|
|
103
|
+
- `'verify-committed-start'` - fired with `(destCoreKey)` after the commit completes
|
|
31
104
|
|
|
32
|
-
|
|
105
|
+
#### `const runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, [options])`
|
|
33
106
|
|
|
34
|
-
|
|
35
|
-
// collect public keys of all signers generated by hypercore-sign
|
|
36
|
-
const publicKeys = ['o37a1...', 'qgbd9...', '6r66j...']
|
|
107
|
+
Commit signed data to a multisig drive.
|
|
37
108
|
|
|
38
|
-
|
|
39
|
-
const namespace = 'holepunchto/my-repo'
|
|
109
|
+
Same parameters and options as `commitCore`, but takes a Hyperdrive instead of a Hypercore.
|
|
40
110
|
|
|
41
|
-
|
|
42
|
-
await store.ready()
|
|
111
|
+
Call `await runner.done()` to get `{ manifest, core, blobsCore, quorum, result }`.
|
|
43
112
|
|
|
44
|
-
|
|
45
|
-
const { manifest, core } = await multisig.createCore(publicKeys, namespace).done()
|
|
46
|
-
```
|
|
113
|
+
## Multisig flow
|
|
47
114
|
|
|
48
|
-
|
|
115
|
+
1. Each signer uses [hypercore-sign](https://github.com/holepunchto/hypercore-sign) to generate a key pair:
|
|
49
116
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
117
|
+
```sh
|
|
118
|
+
hypercore-sign generate-keys
|
|
119
|
+
```
|
|
53
120
|
|
|
54
|
-
|
|
55
|
-
srcCore.append('hello world 2')
|
|
56
|
-
srcCore.append('hello world 3')
|
|
121
|
+
2. Collect all public keys and create a multisig core or drive with `createCore` or `createDrive`.
|
|
57
122
|
|
|
58
|
-
|
|
59
|
-
const { request } = await multisig.requestCore(publicKeys, namespace, srcCore, 3).done()
|
|
60
|
-
```
|
|
123
|
+
3. Generate a signing request with `requestCore` or `requestDrive`.
|
|
61
124
|
|
|
62
|
-
|
|
125
|
+
4. Each signer signs the request using [hypercore-sign](https://github.com/holepunchto/hypercore-sign):
|
|
63
126
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
127
|
+
```sh
|
|
128
|
+
hypercore-sign <signingRequest>
|
|
129
|
+
```
|
|
67
130
|
|
|
68
|
-
|
|
131
|
+
5. Collect all signatures and commit with `commitCore` or `commitDrive`.
|
|
69
132
|
|
|
70
|
-
|
|
71
|
-
// collect signatures from all signers generated by hypercore-sign
|
|
72
|
-
const signatures = [signature1, signature2, ...]
|
|
133
|
+
## License
|
|
73
134
|
|
|
74
|
-
|
|
75
|
-
await multisig.commitCore(publicKeys, namespace, srcCore, request, signatures).done()
|
|
76
|
-
```
|
|
135
|
+
Apache-2.0
|
package/index.js
CHANGED
|
@@ -77,7 +77,6 @@ class HyperMultisig {
|
|
|
77
77
|
return new HyperMultisigRunner(async (runner) => {
|
|
78
78
|
await srcCore.ready()
|
|
79
79
|
this.swarm.join(srcCore.discoveryKey, { client: true, server: false })
|
|
80
|
-
await srcCore.download({ start: 0, end: length }).done()
|
|
81
80
|
|
|
82
81
|
if (!force) await MultisigUtil.verifyCoreRequestable(srcCore, length, { peerUpdateTimeout })
|
|
83
82
|
|