A simple implementation of Shamir's Secret Sharing configured to use a finite field in GF(2^8) with 128 bit padding.
TypeScript variant of https://github.com/jwerle/shamirs-secret-sharing based on version 1.0.1
$ npm install shamirs-secret-sharing-ts
console.logrecovered.toString // 'secret key'
shares = split(secret, opts)
Generate a set of unique and distinct shares for a secret with a configured threshold.
secret(required) - A
stringthat 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
nshares that should be created for this secret
opts.threshold(required) - The number of
ndistinct 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 = 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
Bufferinstances, or strings