New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

secretfracture

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

secretfracture

A simple utility for breaking an ASCII string into cryptographic shares using Shamir's secret sharing.

  • 1.0.11
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
150
decreased by-34.78%
Maintainers
1
Weekly downloads
 
Created
Source

Description

SecretFracture is a threshold secret sharing scheme. This is a cryptographic protocol that will split an ASCII plaintext message into a set of n shares that can be recovered by providing an arbitrary set of k shares. This technique was invented by Israeli cryptographer Adi Shamir; you may read more about this simple and elegant system in his seminal paper How to Share a Secret.

WARNING: This project should not be used in production.

I have only minimal experience in writing cryptographic code and this package is yet to be reviewed by cryptanalysts and security researchers.

Installing and Importing

Install

Install the package in your dependencies by running:

npm i secretfracture --save

Import

Import the core functions into your file by typing:

const {share, recover} = require('secretfracture');

Usage:

Again, DON'T. At least not for anything that could potentially be compromised.

Example of a 3/5 sharing scheme

const {share, recover} = require('secretfracture');

// split the secret into 5 shares, requiring any 3 to recover
const [indices, shares] = share(5, 3, "th15_15_@_53cr37");

console.log(indices, shares);

// recover the secret from the shares
const secret = recover(indices, shares);

console.log(secret);

The output will be something similar to:

[ 1, 2, 3, 4, 5 ] [
  '61872a3bd9080624c46c4f78a7bbcbza',
  '7b0868bd1712af33dda401bdcc263d94',
  'c2edebba1b4f2e8c8b064c01d2b58bf5',
  '3533b232e5bf852ecf942f46b966b421',
  'd6ddbe267361b31aa84cab8b813ab81a'
]
th15_15_@_53cr37

Encoding system

Secret Fracture works by splitting every byte of the ascii plaintext into its own set of shares. The hexadecimal you see output as shares is slightly different from regular hexadecimal. Normally, we can only store bytes with values ranging from 0-255. Since each byte in our secret sharing scheme occurs within a finite field of size 257, we have two values that cannot be represented in hexadecimal. Subsequently, I devised a small convention in which the values 256 and 257 are represented by the pseudo-hex bytes za and zb, respectively. Aside from these two values, the rest of the output shares are interpretable as standard hexadecimal.

Keywords

FAQs

Package last updated on 12 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc