hyper-multisig-cli 0.2.0 → 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 +13 -7
- package/bin.js +95 -169
- package/package.json +1 -1
- package/README.md.orig +0 -169
package/README.md
CHANGED
|
@@ -8,10 +8,12 @@ Includes sanity checks to avoid common mistakes and risky releases, like detecti
|
|
|
8
8
|
|
|
9
9
|
Uses [hyper-multisig](https://github.com/holepunchto/hyper-multisig) under the hood.
|
|
10
10
|
|
|
11
|
+
Supports both Node.js and Bare.
|
|
12
|
+
|
|
11
13
|
## Installation
|
|
12
14
|
|
|
13
15
|
```shell
|
|
14
|
-
npm i -g hyper-multisig-cli
|
|
16
|
+
npm i -g hyper-multisig-cli
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
## Usage
|
|
@@ -66,7 +68,9 @@ Create `multisig.json` in your current directory
|
|
|
66
68
|
|
|
67
69
|
```json
|
|
68
70
|
{
|
|
71
|
+
"type": "core", // core or drive
|
|
69
72
|
"publicKeys": ["paste-here-the-key-generated-by-hypercore-sign-generate-keys"],
|
|
73
|
+
"quorum": 1,
|
|
70
74
|
"namespace": "dummy-test-core",
|
|
71
75
|
"srcKey": "paste-here-the-key-of-your-source-core"
|
|
72
76
|
}
|
|
@@ -79,7 +83,7 @@ It is possible to switch to a different `srcKey`.
|
|
|
79
83
|
### Create Signing Request
|
|
80
84
|
|
|
81
85
|
```shell
|
|
82
|
-
hyper-multisig request
|
|
86
|
+
hyper-multisig request 3
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
You should see an error that the source core is not well seeded. It errors because committing any requests in this situation is dangerous.
|
|
@@ -93,7 +97,7 @@ import IdEnc from 'hypercore-id-encoding'
|
|
|
93
97
|
|
|
94
98
|
const stringKey = '' // use the key of your source core
|
|
95
99
|
|
|
96
|
-
const store = new Corestore(
|
|
100
|
+
const store = new Corestore(`temp-example-seeder-store-${Math.round(Math.random() * 100000)}`)
|
|
97
101
|
const key = IdEnc.decode(stringKey)
|
|
98
102
|
const core = store.get({ key })
|
|
99
103
|
await core.ready()
|
|
@@ -111,7 +115,7 @@ Note: in practice you would use a seeder service, like a [blind-peer](https://gi
|
|
|
111
115
|
Now rerun the command:
|
|
112
116
|
|
|
113
117
|
```shell
|
|
114
|
-
hyper-multisig request
|
|
118
|
+
hyper-multisig request 3
|
|
115
119
|
```
|
|
116
120
|
|
|
117
121
|
Take note of the signing request. It looks like this:
|
|
@@ -132,18 +136,20 @@ yeqmm...
|
|
|
132
136
|
|
|
133
137
|
### Verify Request
|
|
134
138
|
|
|
139
|
+
Replace `yebob...` with your own signing request, and `yeqmm` with your own response. Then run:
|
|
140
|
+
|
|
135
141
|
```
|
|
136
|
-
hyper-multisig verify
|
|
142
|
+
hyper-multisig verify --first-commit yebob... yeqmm...
|
|
137
143
|
```
|
|
138
144
|
|
|
139
145
|
You should see the confirmation that the core is safe to commit.
|
|
140
146
|
|
|
141
147
|
### Commit Request
|
|
142
148
|
|
|
143
|
-
Run the same command as above, but replace 'verify
|
|
149
|
+
Run the same command as above, but replace 'verify' with 'commit'.
|
|
144
150
|
|
|
145
151
|
```
|
|
146
|
-
hyper-multisig commit
|
|
152
|
+
hyper-multisig commit --first-commit <the signing request> <your signing response>
|
|
147
153
|
```
|
|
148
154
|
|
|
149
155
|
You should see logs like
|
package/bin.js
CHANGED
|
@@ -13,17 +13,17 @@ const z32 = require('z32')
|
|
|
13
13
|
const DEFAULT_CONFIG_PATH = './multisig.json'
|
|
14
14
|
const DEFAULT_STORAGE_PATH = './storage'
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
'request
|
|
16
|
+
const cmdRequest = command(
|
|
17
|
+
'request',
|
|
18
18
|
description('Create signing request'),
|
|
19
19
|
flag('--force', 'Skip sanity checks'),
|
|
20
20
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
21
21
|
arg('<length>', 'Core length to request'),
|
|
22
|
-
|
|
22
|
+
request
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
'verify
|
|
25
|
+
const cmdVerify = command(
|
|
26
|
+
'verify',
|
|
27
27
|
description('Verify multisig'),
|
|
28
28
|
flag(
|
|
29
29
|
'--first-commit',
|
|
@@ -32,11 +32,11 @@ const cmdVerifyCore = command(
|
|
|
32
32
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
33
33
|
arg('request', 'Signing request'),
|
|
34
34
|
rest('[...responses]', 'Signing responses'),
|
|
35
|
-
|
|
35
|
+
verify
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
'commit
|
|
38
|
+
const cmdCommit = command(
|
|
39
|
+
'commit',
|
|
40
40
|
description('Commit multisig'),
|
|
41
41
|
flag(
|
|
42
42
|
'--first-commit',
|
|
@@ -46,206 +46,131 @@ const cmdCommitCore = command(
|
|
|
46
46
|
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
47
47
|
arg('request', 'Signing request'),
|
|
48
48
|
rest('[...responses]', 'Signing responses'),
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
const cmdRequestDrive = command(
|
|
53
|
-
'request-drive',
|
|
54
|
-
description('Create signing request'),
|
|
55
|
-
flag('--force', 'Skip sanity checks'),
|
|
56
|
-
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
57
|
-
arg('<length>', 'Drive length to request'),
|
|
58
|
-
requestDrive
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const cmdVerifyDrive = command(
|
|
62
|
-
'verify-drive',
|
|
63
|
-
description('Verify multisig'),
|
|
64
|
-
flag(
|
|
65
|
-
'--first-commit',
|
|
66
|
-
'Set when this is the first commit to the multisig target, so it skips those checks'
|
|
67
|
-
),
|
|
68
|
-
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
69
|
-
arg('request', 'Signing request'),
|
|
70
|
-
rest('[...responses]', 'Signing responses'),
|
|
71
|
-
verifyDrive
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
const cmdCommitDrive = command(
|
|
75
|
-
'commit-drive',
|
|
76
|
-
description('Commit multisig'),
|
|
77
|
-
flag(
|
|
78
|
-
'--first-commit',
|
|
79
|
-
'Set when this is the first commit to the multisig target, so it skips those checks'
|
|
80
|
-
),
|
|
81
|
-
flag('--force-dangerous', 'Advanced option, it might break the drive on misuse'),
|
|
82
|
-
flag('--peer-update-timeout <ms>', 'Peer update timeout in ms'),
|
|
83
|
-
arg('request', 'Signing request'),
|
|
84
|
-
rest('[...responses]', 'Signing responses'),
|
|
85
|
-
commitDrive
|
|
49
|
+
commit
|
|
86
50
|
)
|
|
87
51
|
|
|
88
52
|
const cmd = command(
|
|
89
53
|
'multisig',
|
|
90
54
|
flag('--config|-c <config>', `Config file path (default to ${DEFAULT_CONFIG_PATH})`),
|
|
91
55
|
flag('--storage|-s <storage>', `Storage path (default to ${DEFAULT_STORAGE_PATH})`),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
cmdRequestDrive,
|
|
96
|
-
cmdVerifyDrive,
|
|
97
|
-
cmdCommitDrive,
|
|
56
|
+
cmdRequest,
|
|
57
|
+
cmdVerify,
|
|
58
|
+
cmdCommit,
|
|
98
59
|
() => console.log(cmd.help())
|
|
99
60
|
)
|
|
100
61
|
|
|
101
|
-
async function
|
|
102
|
-
const length = +
|
|
103
|
-
const { force, peerUpdateTimeout } =
|
|
104
|
-
|
|
62
|
+
async function request() {
|
|
63
|
+
const length = +cmdRequest.args.length
|
|
64
|
+
const { force, peerUpdateTimeout } = cmdRequest.flags
|
|
105
65
|
if (!length) throw new Error('Invalid command')
|
|
106
66
|
|
|
107
|
-
const { publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
108
|
-
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
109
|
-
|
|
110
|
-
console.info(`Creating a signing request for hypercore ${srcCore.id} at length ${length}...`)
|
|
111
|
-
console.info('Please ensure this hypercore is seeded') // TODO: reactively based on error instead of always logging
|
|
112
|
-
const multisig = new Multisig(store, swarm)
|
|
113
|
-
const res = await multisig
|
|
114
|
-
.requestCore(publicKeys, namespace, srcCore, length, {
|
|
115
|
-
force,
|
|
116
|
-
peerUpdateTimeout: peerUpdateTimeout,
|
|
117
|
-
quorum
|
|
118
|
-
})
|
|
119
|
-
.done()
|
|
120
|
-
|
|
121
|
-
printRequest(res.request)
|
|
122
|
-
goodbye.exit()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function verifyCore() {
|
|
126
|
-
const { firstCommit, peerUpdateTimeout } = cmdVerifyCore.flags
|
|
127
|
-
const request = cmdVerifyCore.args.request
|
|
128
|
-
const responses = cmdVerifyCore.rest || []
|
|
129
|
-
if (!request) throw new Error('Invalid command')
|
|
130
|
-
|
|
131
|
-
console.info(`Verifying request ${request}`)
|
|
132
|
-
console.info(`Responses:\n -${responses.join('\n -')}`)
|
|
67
|
+
const { type, publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
133
68
|
|
|
134
|
-
const { publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
135
|
-
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
136
69
|
const multisig = new Multisig(store, swarm)
|
|
137
|
-
const runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
138
|
-
dryRun: true,
|
|
139
|
-
skipTargetChecks: firstCommit,
|
|
140
|
-
peerUpdateTimeout: peerUpdateTimeout,
|
|
141
|
-
quorum
|
|
142
|
-
})
|
|
143
|
-
setupProgressLogs(runner, 'core', firstCommit)
|
|
144
70
|
|
|
145
|
-
|
|
71
|
+
let request
|
|
72
|
+
if (type === 'core') {
|
|
73
|
+
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
74
|
+
const res = await multisig
|
|
75
|
+
.requestCore(publicKeys, namespace, srcCore, length, {
|
|
76
|
+
force,
|
|
77
|
+
peerUpdateTimeout: peerUpdateTimeout,
|
|
78
|
+
quorum
|
|
79
|
+
})
|
|
80
|
+
.done()
|
|
81
|
+
request = res.request
|
|
82
|
+
} else {
|
|
83
|
+
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
84
|
+
const res = await multisig
|
|
85
|
+
.requestDrive(publicKeys, namespace, srcDrive, length, {
|
|
86
|
+
force,
|
|
87
|
+
peerUpdateTimeout: peerUpdateTimeout,
|
|
88
|
+
quorum
|
|
89
|
+
})
|
|
90
|
+
.done()
|
|
91
|
+
request = res.request
|
|
92
|
+
}
|
|
93
|
+
printRequest(request)
|
|
146
94
|
|
|
147
|
-
printCommit(res.manifest, res.quorum, res.result, true)
|
|
148
|
-
console.info(`Core key: ${res.result.destCore.key} is safe to commit`)
|
|
149
95
|
goodbye.exit()
|
|
150
96
|
}
|
|
151
97
|
|
|
152
|
-
async function
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
if (!request
|
|
157
|
-
|
|
98
|
+
async function verify() {
|
|
99
|
+
const { firstCommit, peerUpdateTimeout } = cmdVerify.flags
|
|
100
|
+
const request = cmdVerify.args.request
|
|
101
|
+
const responses = cmdVerify.rest || []
|
|
102
|
+
if (!request) throw new Error('Invalid command')
|
|
158
103
|
console.info(`Committing request ${request}`)
|
|
159
104
|
console.info(`Responses:\n -${responses.join('\n -')}`)
|
|
160
105
|
|
|
161
|
-
const { publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
162
|
-
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
106
|
+
const { type, publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
163
107
|
const multisig = new Multisig(store, swarm)
|
|
164
|
-
const runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
165
|
-
skipTargetChecks: firstCommit,
|
|
166
|
-
force: forceDangerous,
|
|
167
|
-
peerUpdateTimeout: peerUpdateTimeout,
|
|
168
|
-
quorum
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
setupProgressLogs(runner, 'core', firstCommit)
|
|
172
|
-
const res = await runner.done()
|
|
173
|
-
|
|
174
|
-
printCommit(res.manifest, res.quorum, res.result)
|
|
175
|
-
console.info(`Core key: ${res.result.destCore.key}`)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async function requestDrive() {
|
|
179
|
-
const length = +cmdRequestDrive.args.length
|
|
180
|
-
const { force, peerUpdateTimeout } = cmdRequestDrive.flags
|
|
181
|
-
if (!length) throw new Error('Invalid command')
|
|
182
108
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
109
|
+
let runner
|
|
110
|
+
if (type === 'core') {
|
|
111
|
+
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
112
|
+
runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
113
|
+
dryRun: true,
|
|
114
|
+
skipTargetChecks: firstCommit,
|
|
189
115
|
peerUpdateTimeout: peerUpdateTimeout,
|
|
190
116
|
quorum
|
|
191
117
|
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (!request) throw new Error('Invalid command')
|
|
203
|
-
console.info(`Committing request ${request}`)
|
|
204
|
-
console.info(`Responses:\n -${responses.join('\n -')}`)
|
|
205
|
-
|
|
206
|
-
const { publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
207
|
-
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
208
|
-
const multisig = new Multisig(store, swarm)
|
|
209
|
-
const runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
210
|
-
dryRun: true,
|
|
211
|
-
skipTargetChecks: firstCommit,
|
|
212
|
-
peerUpdateTimeout: peerUpdateTimeout,
|
|
213
|
-
quorum
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
setupProgressLogs(runner, 'drive', firstCommit)
|
|
118
|
+
} else {
|
|
119
|
+
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
120
|
+
runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
121
|
+
dryRun: true,
|
|
122
|
+
skipTargetChecks: firstCommit,
|
|
123
|
+
peerUpdateTimeout: peerUpdateTimeout,
|
|
124
|
+
quorum
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
setupProgressLogs(runner, type, firstCommit)
|
|
217
128
|
|
|
218
129
|
const res = await runner.done()
|
|
219
130
|
|
|
220
131
|
printCommit(res.manifest, res.quorum, res.result, true)
|
|
221
|
-
|
|
132
|
+
const destKey = type === 'core' ? res.result.destCore.key : res.result.db.destCore.key
|
|
133
|
+
console.info(`${type} key: ${destKey} is safe to commit`)
|
|
222
134
|
goodbye.exit()
|
|
223
135
|
}
|
|
224
136
|
|
|
225
|
-
async function
|
|
226
|
-
const request =
|
|
227
|
-
const responses =
|
|
228
|
-
const { firstCommit, forceDangerous, peerUpdateTimeout } =
|
|
137
|
+
async function commit() {
|
|
138
|
+
const request = cmdCommit.args.request
|
|
139
|
+
const responses = cmdCommit.rest || []
|
|
140
|
+
const { firstCommit, forceDangerous, peerUpdateTimeout } = cmdCommit.flags
|
|
229
141
|
if (!request || !responses?.length) throw new Error('Invalid command')
|
|
230
142
|
|
|
231
143
|
console.info(`Committing request ${request}`)
|
|
232
144
|
console.info(`Responses:\n -${responses.join('\n -')}`)
|
|
233
145
|
|
|
234
|
-
const { publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
235
|
-
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
146
|
+
const { type, publicKeys, namespace, srcKey, quorum, store, swarm } = await setup()
|
|
236
147
|
const multisig = new Multisig(store, swarm)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
148
|
+
|
|
149
|
+
let runner
|
|
150
|
+
if (type === 'core') {
|
|
151
|
+
const srcCore = store.get({ key: idEnc.decode(srcKey) })
|
|
152
|
+
runner = multisig.commitCore(publicKeys, namespace, srcCore, request, responses, {
|
|
153
|
+
skipTargetChecks: firstCommit,
|
|
154
|
+
force: forceDangerous,
|
|
155
|
+
peerUpdateTimeout: peerUpdateTimeout,
|
|
156
|
+
quorum
|
|
157
|
+
})
|
|
158
|
+
} else {
|
|
159
|
+
const srcDrive = new Hyperdrive(store, idEnc.decode(srcKey))
|
|
160
|
+
runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, {
|
|
161
|
+
skipTargetChecks: firstCommit,
|
|
162
|
+
force: forceDangerous,
|
|
163
|
+
peerUpdateTimeout: peerUpdateTimeout,
|
|
164
|
+
quorum
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
setupProgressLogs(runner, type, firstCommit)
|
|
244
168
|
|
|
245
169
|
const res = await runner.done()
|
|
246
170
|
|
|
247
171
|
printCommit(res.manifest, res.quorum, res.result)
|
|
248
|
-
|
|
172
|
+
const destKey = type === 'core' ? res.result.destCore.key : res.result.db.destCore.key
|
|
173
|
+
console.info(`${type} key: ${destKey}`)
|
|
249
174
|
}
|
|
250
175
|
|
|
251
176
|
function setupProgressLogs(req, name, firstCommit) {
|
|
@@ -294,9 +219,9 @@ async function setup() {
|
|
|
294
219
|
const configPath = cmd.flags.config || DEFAULT_CONFIG_PATH
|
|
295
220
|
const storage = cmd.flags.storage || DEFAULT_STORAGE_PATH
|
|
296
221
|
|
|
297
|
-
const { publicKeys, namespace, srcKey, bootstrap, quorum } = await loadConfig(configPath)
|
|
222
|
+
const { type, publicKeys, namespace, srcKey, bootstrap, quorum } = await loadConfig(configPath)
|
|
298
223
|
const { store, swarm } = await replication(storage, bootstrap)
|
|
299
|
-
return { publicKeys, namespace, srcKey, quorum, store, swarm }
|
|
224
|
+
return { type, publicKeys, namespace, srcKey, quorum, store, swarm }
|
|
300
225
|
}
|
|
301
226
|
|
|
302
227
|
/**
|
|
@@ -304,6 +229,7 @@ async function setup() {
|
|
|
304
229
|
*/
|
|
305
230
|
async function loadConfig(configPath) {
|
|
306
231
|
const {
|
|
232
|
+
type,
|
|
307
233
|
publicKeys,
|
|
308
234
|
namespace,
|
|
309
235
|
srcKey,
|
|
@@ -311,12 +237,12 @@ async function loadConfig(configPath) {
|
|
|
311
237
|
quorum = null
|
|
312
238
|
} = JSON.parse(await fs.readFile(configPath, 'utf-8'))
|
|
313
239
|
|
|
314
|
-
if (!publicKeys?.length || !namespace || !srcKey) {
|
|
240
|
+
if (!(type === 'core' || type === 'drive') || !publicKeys?.length || !namespace || !srcKey) {
|
|
315
241
|
throw new Error('Invalid config file')
|
|
316
242
|
}
|
|
317
243
|
|
|
318
244
|
if (bootstrap) console.info(`Using non-default bootstrap`)
|
|
319
|
-
return { publicKeys, namespace, srcKey, bootstrap, quorum }
|
|
245
|
+
return { type, publicKeys, namespace, srcKey, bootstrap, quorum }
|
|
320
246
|
}
|
|
321
247
|
|
|
322
248
|
/**
|
package/package.json
CHANGED
package/README.md.orig
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
# Hyper Multisig CLI
|
|
4
|
-
|
|
5
|
-
CLI to safely create, verify and commit multisig signing requests for hypercores and hyperdrives.
|
|
6
|
-
|
|
7
|
-
Includes sanity checks to avoid common mistakes and risky releases, like detecting conflicts and ensuring all cores are fully seeded by other peers before committing.
|
|
8
|
-
|
|
9
|
-
Uses [hyper-multisig](https://github.com/holepunchto/hyper-multisig) under the hood.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```shell
|
|
14
|
-
npm i -g hyper-multisig-cli@latest
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
```shell
|
|
20
|
-
hyper-multisig --help
|
|
21
|
-
hyper-multisig-bare --help
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Example
|
|
25
|
-
|
|
26
|
-
This example sets up a multisig hypercore with 1 signer and a quorum of 1, so it can be run by a single person. A more standard setup is 3 signers with a quorum of 2.
|
|
27
|
-
|
|
28
|
-
<<<<<<< HEAD
|
|
29
|
-
### Create Signing Key
|
|
30
|
-
|
|
31
|
-
First use [hypercore-sign](https://github.com/holepunchto/hypercore-sign) to create your signing key:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
npm i -g hypercore-sign
|
|
35
|
-
hypercore-sign-generate-keys
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Take note of your public key.
|
|
39
|
-
|
|
40
|
-
### Create Source Core
|
|
41
|
-
|
|
42
|
-
We just create a dummy source core for this example:
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
import Corestore from 'corestore'
|
|
46
|
-
import Hyperswarm from 'hyperswarm'
|
|
47
|
-
|
|
48
|
-
const desiredLength = 3
|
|
49
|
-
|
|
50
|
-
const store = new Corestore('temp-example-store')
|
|
51
|
-
const core = store.get({ name: 'source-core' })
|
|
52
|
-
await core.ready()
|
|
53
|
-
|
|
54
|
-
for (let i = core.length; i < desiredLength; i++) await core.append(`Block-${i}`)
|
|
55
|
-
|
|
56
|
-
const swarm = new Hyperswarm()
|
|
57
|
-
swarm.on('connection', (conn) => { store.replicate(conn) })
|
|
58
|
-
swarm.join(core.discoveryKey)
|
|
59
|
-
console.log(`Swarming key ${core.id} (length ${core.length})`)
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Keep this process running, because we will need to download this hypercore to be able to create and commit the signing request.
|
|
63
|
-
|
|
64
|
-
### Create Config
|
|
65
|
-
|
|
66
|
-
Create `config.json` in your current directory
|
|
67
|
-
=======
|
|
68
|
-
Create `multisig.json`
|
|
69
|
-
>>>>>>> 0db29072a521ab91feb6cb973355c7954b3346a5
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"publicKeys": ["paste-here-the-key-generated-by-hypercore-sign-generate-keys"],
|
|
74
|
-
"namespace": "dummy-test-core",
|
|
75
|
-
"srcKey": "paste-here-the-key-of-your-source-core"
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Note that the key of the multisig hypercore is fully determined by the public keys and namespace. This means you can never use the same namespace with the same signers.
|
|
80
|
-
|
|
81
|
-
It is possible to switch to a different `srcKey`.
|
|
82
|
-
|
|
83
|
-
### Create Signing Request
|
|
84
|
-
|
|
85
|
-
```shell
|
|
86
|
-
hyper-multisig request-core 3 --first-commit
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
You should see an error that the source core is not well seeded. It errors because committing any requests in this situation is dangerous.
|
|
90
|
-
|
|
91
|
-
Fix it by running this script in another terminal window, filling in the correct source key:
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
import Corestore from 'corestore'
|
|
95
|
-
import Hyperswarm from 'hyperswarm'
|
|
96
|
-
import IdEnc from 'hypercore-id-encoding'
|
|
97
|
-
|
|
98
|
-
const stringKey = '' // use the key of your source core
|
|
99
|
-
|
|
100
|
-
const store = new Corestore('temp-example-seeder-store-${Math.random}')
|
|
101
|
-
const key = IdEnc.decode(stringKey)
|
|
102
|
-
const core = store.get({ key })
|
|
103
|
-
await core.ready()
|
|
104
|
-
|
|
105
|
-
const swarm = new Hyperswarm()
|
|
106
|
-
swarm.on('connection', (conn) => { store.replicate(conn) })
|
|
107
|
-
swarm.join(core.discoveryKey)
|
|
108
|
-
console.log(`Swarming key ${core.id}`)
|
|
109
|
-
|
|
110
|
-
core.download({ start: 0, end: -1 })
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Note: in practice you would use a seeder service, like a [blind-peer](https://github.com/holepunchto/blind-peer), to ensure your source core is well seeded. Having two seeder processes running locally is not safe (if your computer is turned off, the core is no longer available).
|
|
114
|
-
|
|
115
|
-
Now rerun the command:
|
|
116
|
-
|
|
117
|
-
```shell
|
|
118
|
-
hyper-multisig request-core 3 --first-commit
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Take note of the signing request. It looks like this:
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
hypercore-sign yebob...
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Sign Request
|
|
128
|
-
|
|
129
|
-
Run the hypercore-sign command, and take note of the result. It looks like
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
Reply with:
|
|
133
|
-
|
|
134
|
-
yeqmm...
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Verify Request
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
hyper-multisig verify-core --first-commit <the signing request> <your signing response>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
You should see the confirmation that the core is safe to commit.
|
|
144
|
-
|
|
145
|
-
### Commit Request
|
|
146
|
-
|
|
147
|
-
Run the same command as above, but replace 'verify-core' with 'commit-core'.
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
hyper-multisig commit-core --first-commit <the signing request> <your signing response>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
You should see logs like
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
Verifying the core is safe to commit (source <source key> to multisig target <target key>)
|
|
157
|
-
Opened connection
|
|
158
|
-
Opened connection
|
|
159
|
-
Committing the core...
|
|
160
|
-
Committed the core (key <target key>)
|
|
161
|
-
Waiting for remote seeders to pick up the changes...
|
|
162
|
-
Please add this key to the seeders now. The logs here will notify you when it is picked up by them. Do not shut down until that happens.
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Do as the logs instruct, and add your target key to 2 or more seeders. For this example, simple run 2 more seeder scripts like above, but this time for the target key.
|
|
166
|
-
|
|
167
|
-
Once the program detects at least 2 seeders have fully downloaded the multisig drive, it will inform you it is done. Shut down with ctrl-c.
|
|
168
|
-
|
|
169
|
-
Note: for any future updates to your multisig core, remove the `first-commit` flag.
|