Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipfs #11

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Ipfs #11

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
made exported function names more descriptive
Hadas Zeilberger authored and Hadas Zeilberger committed Nov 13, 2018
commit a71c0552d8bf68e5af479e4fbd8f3b1c31961544
9 changes: 6 additions & 3 deletions ExampleGrinder/App.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,10 @@
/*eslint no-unused-vars: "warn"*/
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { encryptAndSplitSecret, combineAndDecryptSecret } from '../index';
import {
encryptSplitAndSpreadSecret,
collectCombineAndDecryptSecret
} from '../index';
const secret = 'shamir';
type Props = {};
/**
@@ -20,8 +23,8 @@ export default class App extends Component<Props> {
* Good place for data fetching
*/
async componentDidMount() {
let locationsAndIv = await encryptAndSplitSecret(secret, 5, 3);
let combinedAndDecryptedSecret = await combineAndDecryptSecret(
let locationsAndIv = await encryptSplitAndSpreadSecret(secret, 5, 3);
let combinedAndDecryptedSecret = await collectCombineAndDecryptSecret(
locationsAndIv.locations,
locationsAndIv.iv
);
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { getFromIPFS, storeToIPFS } from './lib/remoteStorage.js';
* @param {number} numShares - number of shares you want to "split" the secret into
* @param {number} threshold - minimum number of shares needed to reconstruct the secret
*/
export async function encryptAndSplitSecret(secret, numShares, threshold) {
export async function encryptSplitAndSpreadSecret(secret, numShares, threshold) {
let sssa = new SSSA(8);
let key = await getKey();
if (!key) {
@@ -24,7 +24,7 @@ export async function encryptAndSplitSecret(secret, numShares, threshold) {
/**@param {Array} ipfsLocations - IPFS locations - an array of locations of shares from which to construct the secret
* @param {string} iv - a base64 string used as an initialization vector when encrypting the file
*/
export async function combineAndDecryptSecret(ipfsLocations, iv) {
export async function collectCombineAndDecryptSecret(ipfsLocations, iv) {
let key = await getKey();
let sssa = new SSSA(8);
let sharesFromIPFS = await getFromIPFS(ipfsLocations);