Skip to content
Snippets Groups Projects
Commit 5a27c1f8 authored by Sasha Ilieva's avatar Sasha Ilieva
Browse files

Add secrets.js

parent ae78d8ef
No related branches found
No related tags found
1 merge request!88908 account recovery ability to add contacts to trusted contacts list for account recovery
import { secrets } from "secrets.js-grempe";
export /**
* Function generates a random bits length string, and output it in hexadecimal format
*
* @param {number} bits
*/
const generateRecoveryKey = bits => secrets.random(bits);
/**
* Divide a secret expressed in hexadecimal form into numShares number of shares, requiring that threshold number of shares be present for reconstructing the secret
*
* @param {string} secret
* @param {number} numShares
* @param {number} threshold
* @param {number} [padLength=128]
*/
export const divideSecretToShares = (
secret,
numShares,
threshold,
padLength = 128
) => secrets.share(secret, numShares, threshold, padLength);
/**
* Reconstructs a secret from shares
*
* @param {array} shares
*/
export const combineSecret = shares => secrets.combine(shares);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment