@tanle/shamirs-secret-sharing
v0.0.2
Published
A JS/TS implementation of Shamir's Secret Sharing in a finite field GF(2^8)
Downloads
158
Readme
Shamir's Secret Sharing
A JS/TS implementation of Shamir's Secret Sharing in a finite field GF(2^8).
Example
import { split, reconstruct } from "@tanle/shamirs-secret-sharing/sss-28";
// No limit the length of the secret as GF(2^8) works over each byte
const secretStr = "helloworld";
const secret = new Uint8Array(Buffer.from(secretStr, "utf-8"));
const threshold = 2; // must be in [0, 255]
const numShares = 2; // must be in [0, 255]
const shares = split(secret, threshold, numShares);
const reSecret = reconstruct(shares);
const reSecretStr = Buffer.from(reSecret).toString("utf-8");
console.log(secretStr, reSecretStr);