INNER CODE UNIT · TypeScript
secretLength
privy-io/shamir-secret-sharing · src/index.ts:300
const secretLength = shareLength - 1;
const secret = new Uint8Array(secretLength);
const xSamples = new Uint8Array(sharesLength);
const ySamples = new Uint8Array(sharesLength);
const samples: Set<number> = new Set();
for (let i = 0; i < sharesLength; i++) {
const share = shares[i]!;
const sample = share[shareLength - 1]!;
// The last byte of each share should be a unique value between 1-255 inclusive.
if (samples.has(sample)) {
throw new Error('shares must contain unique values but a duplicate was found');
}
samples.add(sample);
xSamples[i] = sample;