INNER CODE UNIT · TypeScript

n

blueshift-gg/doppler · packages/core/index.ts:109

    n = n * 58n + BigInt(digit);
  }
  const bytes = new Uint8Array(32);
  let valueBytes = 0;
  for (let i = 31; n > 0n; i--, n >>= 8n) {
    bytes[i] = Number(n & 0xffn);
    valueBytes++;
  }
  if (zeros + valueBytes !== 32) throw new TypeError(`${what}: a key is 32 bytes in base58`);
  return bytes;
}

function base58(bytes: Uint8Array): string {
  let zeros = 0;
  while (zeros < bytes.length && bytes[zeros] === 0) zeros++;

  let n = 0n;
  for (let i = zeros; i < bytes.length; i++) n = (n << 8n) | BigInt(bytes[i]!);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…