npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shamirs-secret-sharing-es

v1.0.4

Published

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

Downloads

10

Readme

shamirs-secret-sharing-ts

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

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-ts

Example Usage

import { split, combine } from 'shamirs-secret-sharing-ts'

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

In Angular 2 or higher add following to polyfills.ts

(window as any).global = window;
// @ts-ignore
window.Buffer = window.Buffer || require('buffer').Buffer;

API

shares = 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 = 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

  • https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing
  • https://en.wikipedia.org/wiki/Secret_sharing
  • https://en.wikipedia.org/wiki/Lagrange_polynomial
  • https://en.wikipedia.org/wiki/Horner%27s_method
  • https://en.wikipedia.org/wiki/Pseudorandom_number_generator
  • https://codesandbox.io/s/shamirs-secret-sharing-pcsbk

License

MIT