Giter Club home page Giter Club logo

react-native-sssa's Introduction

React Native SSSA

Shamir's Secret Sharing Algorithm For React-Native

Installation โˆ™ Usage

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

react-native-sssa's People

Contributors

barlock avatar hadasz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-sssa's Issues

Add Support for Android

This hasn't been tested on Android and there are several issues preventing it from working

Error on Android with generateShares method

It works great on iOS but when running the exact same code on Android I get the following error when using generateShares method:

TypeError: undefined is not a function (evaluating '(0, _base64Js.toByteArray)(base64).reverse()')

Do you know what might be happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.