From 71b7d5e1368c683b4a9fb052d409d86a20126da0 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 14 Nov 2018 12:46:42 -0500 Subject: [PATCH 1/2] edited the installation section --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7ff3b26..e8c3112 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,16 @@ $ 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 + From 0d249954aa8a6fc074068075b392a60bb042b0cc Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 14 Nov 2018 14:58:51 -0500 Subject: [PATCH 2/2] added usage to readme --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e8c3112..32f4ee6 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ $ yarn add react-native-sssa react-native-securerandom react-native-aes-crypto r $ react-native link ``` -[react-native-securerandom] is used to provide entropy in shamir's secret sharing algorithm +**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-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 +**react-native-secure-storage** is used to securely stored the private key If need be, their documentation provides instructions for manual linking: @@ -32,4 +32,25 @@ their documentation provides instructions for 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); +