Skip to content
Open
Changes from all commits
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
9 changes: 8 additions & 1 deletion src/functions/shamir_secret_sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ module.exports = function (S) {
return shares;
};

S.__restore_secret = (shares) => {
S.__restore_secret = (shares, threshold) => {
if (threshold === undefined) {
throw new Error("Threshold parameter is required. Call __restore_secret(shares, threshold)");
}
const shareCount = Object.keys(shares).length;
if (shareCount < threshold) {
throw new Error(`Need at least ${threshold} shares to recover the secret, but only ${shareCount} provided`);
}
let secret = BF([]);
let shareLength = null;
let q = [];
Expand Down