Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 2.15 KB

README.md

File metadata and controls

51 lines (37 loc) · 2.15 KB

React Native SSSA

Shamir's Secret Sharing Algorithm For React-Native

InstallationUsage

A react-native library for generating cryptographically secure shares of a secret. Currently only supported and tested on iOS. If you are interested in contributing to it working for android, here's an issue to start on

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);