Skip to content
Snippets Groups Projects

908 account recovery ability to add contacts to trusted contacts list for account recovery

Compare and
4 files
+ 41
1
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 34
0
 
import { secrets } from "secrets.js-grempe";
 
import { encryptMessage } from "./signingUtilities.js";
 
 
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);
 
 
export const encryptShare = (share, publicKey) =>
 
encryptMessage(share, publicKey, "secretPart");
Loading