UNPKG

capacitor-shamir

Version:

Provides Shamir's Secret Sharing (SSS) functionality for secure splitting and recovering secrets natively on iOS, Android, and Web.

24 lines (23 loc) 1.12 kB
export type RandomBytes = (length: number) => Uint8Array; export type Parts = Record<string, Uint8Array>; /** * Calculates f(partIdx) of the given points using Lagrangian interpolation. * @param {Uint8Array} points The supplied point. * @param {Number} partIdx The index to interpolate at. */ export declare function interpolate(points: Uint8Array[], partIdx?: number): number; /** * Generates a random polynomal of the correct degree and sets x as the first coefficient. * @param {(number) => Uint8Array} randomBytes Takes a length and returns a * Uint8Array of that length. * @param {number} d The degree of the polynomial driven by the number shares and join threshold. * @param {number} x The point to hide. * @return {Uint8Array} The random polynomial with x as the fist coefficient. */ export declare function generate(randomBytes: RandomBytes, d: number, x: number): Uint8Array; /** * Evaluates a polynomal at point x using Horner's method. * @param {Uint8Array} p The polynomial * @return {Number} x The point to evaluate. */ export declare function evaluate(p: Uint8Array, x: number): number;