JSPM

react-native-sssa

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q36393F

shamir secret sharing algorithm for react-native

Package Exports

  • react-native-sssa

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-sssa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Native SSSA

Shamir's Secret Sharing Algorithm For React-Native

InstallationUsage

A library to generate cryptographically secure shares of a secret.

Installation

$ yarn add react-native-sssa react-native-securerandom react-native-aes-crypto react-native-secure-storage
$ react-native link

react-native-securerandom is used to provide entropy in shamir's secret sharing algorithm

react-native-aes-crypto is used to encrypt a file with AES before being processed with SSSA

react-native-secure-storage is used to securely stored the private key

Usage

To put a plain text secret through the entire pipeline (encrypt with. AES, generate shares of the secret with Shamir's Secret Sharing Algorithm, and distribute shares to IPFS (via Infura), use the following:

import {encryptSplitAndSpreadSecret} from 'react-native-sssa';
let ipfsHashes = await encryptSplitAndSpreadSecret(secret,numShares,threshold)

To collect shares back from IPFS, use Shamir's secret sharing algorithm to reconstruct the encrypted file, and then decrypt the file back to the plain-text secret, do:

import {collectCombineAndDecryptSecret} from 'react-native-sssa';
let secret = await collectCombineAndDecryptSecret(ipfsHashes)

If you just want to use Shamir's Secret Sharing Algorithm alone without encryption and IPFS, do the following:

import SSSA from 'react-native-sssa';
//This does secret sharing with 3 bit coefficients in the field GF(2^3).
let sssa = new SSSA(3); 
let shares = sssa.generateShares(base64Secret,numShares,threshold);
let secret = sssa.combine(shares);