INNER CODE UNIT · TypeScript

diff

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

  const diff = (logA - logB + 255) % 255;
  const result = EXP_TABLE[diff]!;

  return a === 0 ? 0 : result;
}

// Multiplies two numbers in GF(2^8).
function mult(a: number, b: number): number {
  if (!Number.isInteger(a) || a < 0 || a > 255) {
    throw new RangeError('Number is out of Uint8 range');
  }
  if (!Number.isInteger(b) || b < 0 || b > 255) {
    throw new RangeError('Number is out of Uint8 range');
  }
  const logA = LOG_TABLE[a]!;
  const logB = LOG_TABLE[b]!;
  const sum = (logA + logB) % 255;
  const result = EXP_TABLE[sum]!;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…