shamirs-secret-sharing-ts
Version:
A simple implementation of Shamir's Secret Sharing configured to use a finite field in GF(2^8) with 128 bit padding
19 lines (18 loc) • 617 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
const zeroes = new Array(4 * constants_1.BIT_SIZE).join('0');
exports.zeroes = zeroes;
const logs = new Array(constants_1.BIT_SIZE).fill(0);
exports.logs = logs;
const exps = new Array(constants_1.BIT_SIZE).fill(0);
exports.exps = exps;
for (let i = 0, x = 1; i < constants_1.BIT_SIZE; ++i) {
exps[i] = x;
logs[x] = i;
x = x << 1;
if (x >= constants_1.BIT_SIZE) {
x = x ^ constants_1.PRIMITIVE_POLYNOMIAL;
x = x & constants_1.MAX_SHARES;
}
}