hyper-multisig 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.
Files changed (2) hide show
  1. package/README.md +106 -47
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,75 +2,134 @@
2
2
 
3
3
  # Hyper Multisig
4
4
 
5
- - Create multisig hypercores and hyperdrives
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 other peers etc.)
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
- ## Install
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 i hyper-multisig
14
+ npm install -g hyper-multisig
15
15
  ```
16
16
 
17
- ## Usage
17
+ ## API
18
18
 
19
- End users most likely want to use [hyper-multisig-cli](https://github.com/holepunchto/hyper-multisig-cli) instead of interacting directly with this module.
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
- ## Multisig Flow
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
- - Step 1: Each signer uses [hypercore-sign](https://github.com/holepunchto/hypercore-sign) to generate a key pair (secret key and public key). Later, public keys from all signers will be collected to create a multisig core.
97
+ Call `await runner.done()` to get `{ manifest, core, quorum, result }` where `quorum` is the amount of valid signatures.
24
98
 
25
- ```shell
26
- hypercore-sign generate-keys
99
+ The runner emits events during the commit process:
27
100
 
28
- # to create an additional key pair
29
- HYPERCORE_SIGN_KEYS_DIRECTORY=<path-to-another-dir> hypercore-sign generate-keys
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
- - Step 2: Create a multisig core given the public keys from the previous step, and a namespace to avoid collisions (the combination signers-namespace has to be globally unique, as it determinstically defines the key of the resulting multisig hypercore).
105
+ #### `const runner = multisig.commitDrive(publicKeys, namespace, srcDrive, request, responses, [options])`
33
106
 
34
- ```js
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
- // to avoid collision, we structure namespace based on repo path
39
- const namespace = 'holepunchto/my-repo'
109
+ Same parameters and options as `commitCore`, but takes a Hyperdrive instead of a Hypercore.
40
110
 
41
- const store = new Corestore('storage')
42
- await store.ready()
111
+ Call `await runner.done()` to get `{ manifest, core, blobsCore, quorum, result }`.
43
112
 
44
- const multisig = new HyperMultisig(store, swarm)
45
- const { manifest, core } = await multisig.createCore(publicKeys, namespace).done()
46
- ```
113
+ ## Multisig flow
47
114
 
48
- - Step 3: Generate a signing request based on a normal core (non-multisig) with the manifest from the previous step.
115
+ 1. Each signer uses [hypercore-sign](https://github.com/holepunchto/hypercore-sign) to generate a key pair:
49
116
 
50
- ```js
51
- const srcCore = store.get({ name: 'my-core' })
52
- await srcCore.ready()
117
+ ```sh
118
+ hypercore-sign generate-keys
119
+ ```
53
120
 
54
- srcCore.append('hello world 1')
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
- const multisig = new HyperMultisig(store)
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
- - Step 4: Use [hypercore-sign](https://github.com/holepunchto/hypercore-sign) to sign the signing request to generate a signature. Later, signatures from all signers will be collected to sign the multisig core.
125
+ 4. Each signer signs the request using [hypercore-sign](https://github.com/holepunchto/hypercore-sign):
63
126
 
64
- ```shell
65
- hypercore-sign <signingRequest>
66
- ```
127
+ ```sh
128
+ hypercore-sign <signingRequest>
129
+ ```
67
130
 
68
- - Step 5: Commit the multisig core with the signatures from the previous step.
131
+ 5. Collect all signatures and commit with `commitCore` or `commitDrive`.
69
132
 
70
- ```js
71
- // collect signatures from all signers generated by hypercore-sign
72
- const signatures = [signature1, signature2, ...]
133
+ ## License
73
134
 
74
- const multisig = new HyperMultisig(store, swarm)
75
- await multisig.commitCore(publicKeys, namespace, srcCore, request, signatures).done()
76
- ```
135
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyper-multisig",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "Multisig hypercore and hyperdrive",
5
5
  "main": "index.js",
6
6
  "files": [