Skip to content

πŸ”‘ Node.js bindings to RustySecrets, a secret sharing scheme implementation written in Rust

License

Notifications You must be signed in to change notification settings

SpinResearch/rustysecrets-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

rustysecrets-node

Build Status npm License

Node.js bindings to RustySecrets, a secret sharing scheme library written in Rust.

Requirements

  • Node.js v8.x LTS (Carbon) or Electron >= 1.7.x
  • Rust stable (eg. via rustup)

Installation

$ npm install --save rusty-secrets

Usage

var 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!

API

rustysecrets : object

rustysecrets.sss : object

Provides an API to perform Shamir's secret sharing, with optional signatures

Kind: static namespace of rustysecrets

sss.splitSecret(k, n, secret, signShares) β‡’ Array.<String>

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.

sss.recoverSecret(shares, verifySignatures) β‡’ String

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 verifySignatures is 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

rustysecrets.wrapped : object

Provides an API to perform Shamir's secret sharing, with MIME types

Kind: static namespace of rustysecrets

wrapped.splitSecret(k, n, secret, mimeType, signShares, cb)

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.

wrapped.recoverSecret(shares, verifySignatures, cb)

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.

Bug Reporting

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.

License

See LICENSE