INNER CODE UNIT · TypeScript

main

paulmillr/noble-ciphers · benchmark/ciphers.ts:21

async function main() {
  const key = buf(32);
  const key64 = buf(64);
  const nonce = buf(12);
  const nonce8 = buf(8);
  const nonce16 = buf(16);
  const nonce24 = buf(24);

  const warm = buf(64);
  await warmup(() => xsalsa20poly1305(key, nonce24).encrypt(warm));
  for (const { size, data: buf } of buffers) {
    section(size, { bytes: buf, mode: buf.byteLength === 64 ? 'time' : 'normal' });
    await bench('xsalsa20poly1305', () => xsalsa20poly1305(key, nonce24).encrypt(buf));
    await bench('chacha20poly1305', () => chacha20poly1305(key, nonce).encrypt(buf));
    await bench('xchacha20poly1305', () => xchacha20poly1305(key, nonce24).encrypt(buf));
    await bench('aes-gcm-256', () => gcm(key, nonce).encrypt(buf));
    await bench('aes-gcm-siv-256', () => gcmsiv(key, nonce).encrypt(buf));
    await bench('aes-siv-256', () => aessiv(key, nonce, nonce16, nonce24).encrypt(buf));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…