Node.js bindings to RustySecrets, a secret sharing scheme library written in Rust.
- Node.js v8.x LTS (Carbon) or Electron >= 1.7.x
 - Rust stable (eg. via rustup)
 
$ npm install --save rusty-secretsvar rustysecrets = require('rusty-secrets').wrapped;
var threshold   = 7;
var sharesCount = 10;
var secret      = "Hello, World";
var shares = rustysecrets.splitSecret(threshold, sharesCount, secret);
// > [ '7-1-CgyDwB3wLPHL4hinb1o',
// >   '7-2-CgzDMo5J6YvrIIHFahg',
// >   '7-3-CgwIl//VqlYAlfYQaSY',
// >   '7-4-CgxDy7Umfn+rua4BYJw',
// >   '7-5-CgyIbsS6PaJADNnUY6I',
// >   '7-6-CgzInFcD+NhgzkC2ZuA',
// >   '7-7-CgwDOSafuwWLezdjZd4',
// >   '7-8-CgxeJMP4TYorlvCUdIk',
// >   '7-9-CgyVgbJkDlfAI4dBd7c',
// >   '7-10-CgzVcyHdyy3g4R4jcvU' ]
var someShares = shares.slice(1, 8);
var recovered = rustysecrets.recoverSecret(someShares);
// > Hello, World!- rustysecrets : 
object- .sss : 
object- .splitSecret(k, n, secret, signShares) β 
Array.<String> - .recoverSecret(shares, verifySignatures) β 
String 
 - .splitSecret(k, n, secret, signShares) β 
 - .wrapped : 
object 
 - .sss : 
 
Provides an API to perform Shamir's secret sharing, with optional signatures
Kind: static namespace of rustysecrets
- .sss : 
object- .splitSecret(k, n, secret, signShares) β 
Array.<String> - .recoverSecret(shares, verifySignatures) β 
String 
 - .splitSecret(k, n, secret, signShares) β 
 
Performs k-out-of-n Shamir's secret sharing.
Kind: static method of sss
Returns: Array.<String> - An array of shares
Throws:
- Will throw an error if the parameters are invalid.
 
| Param | Type | Description | 
|---|---|---|
| k | Number | 
Minimum number of shares to be provided to recover the secret (1 <= k <= 255). | 
| n | Number | 
Number of shares to emit (2 <= n <= 255). | 
| secret | Buffer | 
The secret to split. | 
| signShares | Boolean | 
Sign the shares using Merkle signing. | 
Recovers the secret from a k-out-of-n Shamir's secret sharing scheme.
At least k distinct shares need to be provided to recover the secret.
Kind: static method of sss
Returns: String - The recovered secret
Throws:
- Will throw an error if there are not enough shares.
 - Will throw an error if the shares are invalid.
 - Will throw an error if the shares data is not well-formed.
 - Will throw an error if 
verifySignaturesis not set to the proper value. 
| Param | Type | Description | 
|---|---|---|
| shares | Array.<String> | 
The shares to recover the secret from. | 
| verifySignatures | Boolean | 
Verify the signatures.  Must be set to true if they are signed, false otherwise | 
Provides an API to perform Shamir's secret sharing, with MIME types
Kind: static namespace of rustysecrets
- .wrapped : 
object 
Performs k-out-of-n Shamir's secret sharing.
Kind: static method of wrapped
| Param | Type | Description | 
|---|---|---|
| k | Number | 
Minimum number of shares to be provided to recover the secret (1 <= k <= 255). | 
| n | Number | 
Number of shares to emit (2 <= n <= 255). | 
| secret | Buffer | 
The secret to split. | 
| mimeType | Buffer | 
The MIME type of the secret (or null). | 
| signShares | Boolean | 
Sign the shares using Merkle signing. | 
| cb | function | 
The callback to call with the result. | 
Recovers the secret from a k-out-of-n Shamir's secret sharing scheme.
At least k distinct shares need to be provided to recover the secret.
Kind: static method of wrapped
| Param | Type | Description | 
|---|---|---|
| shares | Array.<String> | 
The shares to recover the secret from. | 
| verifySignatures | Boolean | 
Verify the signatures.  Must be set to true if they are signed, false otherwise | 
| cb | function | 
The callback to call with the result. | 
Please report bugs either as pull requests or as issues in the issue tracker. rustysecrets-node has a full disclosure vulnerability policy. Please do NOT attempt to report any security vulnerability in this code privately to anybody.
See LICENSE