INNER CODE UNIT · TypeScript

split

privy-io/shamir-secret-sharing · src/index.ts:221

export async function split(
  secret: Uint8Array,
  shares: number,
  threshold: number,
): Promise<Uint8Array[]> {
  // secret must be a non-empty Uint8Array
  AssertArgument.instanceOf(secret, Uint8Array, 'secret must be a Uint8Array');
  AssertArgument.greaterThanOrEqualTo(secret.byteLength, 1, 'secret cannot be empty');

  // shares must be a number in the range [2, 256)
  AssertArgument.instanceOf(shares, Number, 'shares must be a number');
  AssertArgument.inRange(shares, 2, 256, 'shares must be at least 2 and at most 255');

  // threshold must be a number in the range [2, 256)
  AssertArgument.instanceOf(threshold, Number, 'threshold must be a number');
  AssertArgument.inRange(threshold, 2, 256, 'threshold must be at least 2 and at most 255');

  // total number of shares must be greater than or equal to the required threshold

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…