Create and manage multisig hypercores and hyperdrives.
Includes sanity checks to avoid common mistakes and risky releases (detecting conflicts before committing, ensuring all cores are seeded by multiple peers, etc.)
End users most likely want to use hyper-multisig-cli instead of interacting directly with this module.
npm install -g hyper-multisig
Create a new HyperMultisig instance.
store- a Corestore instanceswarm- a Hyperswarm instance
Create a multisig hypercore.
publicKeys- array of z32-encoded public keys from all signersnamespace- 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)
Options include:
- quorum: minimum number of signatures required, defaults to half of public keys + 1
Returns { manifest, key, core } where core is a read-only Hypercore.
const { manifest, key, core, blobsManifest, blobsKey, blobsCore } = await multisig.createDrive(publicKeys, namespace, [options])
Create a multisig hyperdrive (with associated blobs core).
Same parameters and options as createCore.
Generate a signing request from a source core.
publicKeys- array of public keysnamespace- namespace stringsrcCore- source Hypercore to create a request forlength- length of the source core to use for the request
Options include:
{
force: false, // skip verification checks
quorum, // override default quorum
peerUpdateTimeout: 5000 // timeout in ms for peer updates
}Call await runner.done() to get { manifest, request }. The request is the signing request, as a buffer.
Generate a signing request for a source drive.
Same parameters and options as requestCore, but takes a Hyperdrive instead of a Hypercore.
Call await runner.done() to get { manifest, request }.
Commit signed data to a multisig core.
publicKeys- array of public keysnamespace- namespace stringsrcCore- source Hypercore that was signedrequest- the signing requestresponses- array of signed responses from signers
Options include:
{
quorum, // override default quorum
dryRun: false, // perform validation without committing
force: false, // advanced option, and dangerous
skipTargetChecks: false, // only useful for the first commit
peerUpdateTimeout: 5000, // timeout in ms for peer updates
minFullCopies: 2 // minimum number of peers with a full copy of the core
}Call await runner.done() to get { manifest, core, quorum, result } where quorum is the amount of valid signatures.
The runner emits events during the commit process:
'verify-committable-start'- fired with(srcCoreKey, destCoreKey)'commit-start'- fired when the commit begins'verify-committed-start'- fired with(destCoreKey)after the commit completes
Commit signed data to a multisig drive.
Same parameters and options as commitCore, but takes a Hyperdrive instead of a Hypercore.
Call await runner.done() to get { manifest, core, blobsCore, quorum, result }.
-
Each signer uses hypercore-sign to generate a key pair:
hypercore-sign generate-keys
-
Collect all public keys and create a multisig core or drive with
createCoreorcreateDrive. -
Generate a signing request with
requestCoreorrequestDrive. -
Each signer signs the request using hypercore-sign:
hypercore-sign <signingRequest>
-
Collect all signatures and commit with
commitCoreorcommitDrive.
Apache-2.0