INNER CODE UNIT · TypeScript
newCoefficients
privy-io/shamir-secret-sharing · src/index.ts:148
function newCoefficients(intercept: number, degree: number): Readonly<Uint8Array> {
const coefficients = new Uint8Array(degree + 1);
coefficients[0] = intercept;
coefficients.set(getRandomBytes(degree), 1);
return coefficients;
}
// Creates a set of values from [1, 256).
// Returns a psuedo-random shuffling of the set.
function newCoordinates(): Readonly<Uint8Array> {
const coordinates = new Uint8Array(255);
for (let i = 0; i < 255; i++) {
coordinates[i] = i + 1;
}
// Pseudo-randomize the array of coordinates.
//
// This impl maps almost perfectly because both of the lists (coordinates and randomIndices)