diff --git a/README.md b/README.md index 7ff3b26..32f4ee6 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,37 @@ $ yarn add react-native-sssa react-native-securerandom react-native-aes-crypto r $ react-native link ``` -This package relies on [react-native-securerandom](https://github.com/rh389/react-native-securerandom) to provide entropy in shamir's secret sharing algorithm, [react-native-aes-crypto] to provide encryption to secret before being processed by sssa, and [react-native-secure-storage] to safetly store and retrieve private key -It has native dependencies that need linking. -If need be, -their documentation provides instructions for [manual linking](https://github.com/rh389/react-native-securerandom#manual-linking) +**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 encrypted with SSSA + +**react-native-secure-storage** is used to securely stored the private key +If need be, +their documentation provides instructions for manual linking: +[react-native-securerandom](https://github.com/rh389/react-native-securerandom#manual-linking) +[react-native-secure-storage](https://github.com/oyyq99999/react-native-secure-storage#manual-installation) +[react-native-aes-crypto] (https://github.com/tectiv3/react-native-aes#Installation) ## 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: + +```javascript +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: + +```javascript +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: + +```javascript +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); + +