@consento/shamirs-secret-sharing
A simple implementation of Shamir's Secret Sharing configured to use a finite field in GF(2^8) with 128 bit padding
Last updated 10 months ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @consento/shamirs-secret-sharing 
SYNC missed versions from official npm registry.

shamirs-secret-sharing

A simple implementation of Shamir's Secret Sharing configured to use a finite field in GF(2^8) with 128 bit padding.

Preface

Much of what you see in this module has been ported from or directly influenced by secrets.js, c-sss, and libgfshare

Installation

$ npm install shamirs-secret-sharing

Example Usage

const sss = require('shamirs-secret-sharing')
const secret = Buffer.from('secret key')
const shares = sss.split(secret, { shares: 10, threshold: 4 })
const recovered = sss.combine(shares.slice(3, 7))
console.log(recovered.toString()) // 'secret key'

API

shares = sss.split(secret, opts)

Generate a set of unique and distinct shares for a secret with a configured threshold.

  • secret (required) - A Buffer instance or string that represents a secret for which shares are created for
  • opts (required) - An object of options for configuring how shares are created for a secret
    • opts.shares (required) - The number of n shares that should be created for this secret
    • opts.threshold (required) - The number of t of n distinct share that are required to reconstruct this secret
    • opts.random (optional) - An optional Pseudorandom number generator (PRNG) function that should generate a random value buffer based on some input. e.g opts.random = (size) => randomBytes(size)

secret = sss.combine(shares)

Reconstruct a secret from a distinct set of shares. This function will not throw an error for incorrect shares or if p(0) is not the correct secret for the given shares.

  • shares (required) - An array of shares, that is an array of equally sized and distinct Buffer instances, or strings

See Also

License

MIT

Current Tags

  • 1.0.4                                ...           latest (10 months ago)

3 Versions

  • 1.0.4                                ...           10 months ago
  • 1.0.3                                ...           10 months ago
  • 1.0.2                                ...           10 months ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |