Security & Cryptography Benchmarks

Read time 5 minutes
On this page

Detailed performance metrics for the Nalix security primitives, including encryption ciphers, handshake computation, and hashing algorithms.

Envelope Cipher Suites

Comparison of stream ciphers (Salsa20 and ChaCha20) and AEAD suites (Salsa20-Poly1305 and ChaCha20-Poly1305) over 64 B and 1024 B payloads. All operations are run on zero-allocation spans.

Envelope Cipher Performance (Payload Size = 64)

MethodPayloadSizeMeanErrorStdDevP95Allocated
Encrypt_Salsa2064331.0 ns10.13 ns11.66 ns342.7 ns0 B
Decrypt_Salsa2064260.2 ns5.27 ns6.07 ns265.0 ns0 B
Encrypt_Chacha2064343.4 ns4.49 ns5.17 ns347.8 ns0 B
Decrypt_Chacha2064260.1 ns6.18 ns7.12 ns263.5 ns0 B
Encrypt_Salsa20Poly130564734.6 ns27.18 ns31.30 ns752.7 ns0 B
Decrypt_Salsa20Poly130564712.0 ns95.41 ns109.87 ns773.4 ns0 B
Encrypt_Chacha20Poly130564511.2 ns5.81 ns6.69 ns520.5 ns0 B
Decrypt_Chacha20Poly130564484.0 ns3.58 ns4.13 ns492.0 ns0 B

Envelope Cipher Performance (Payload Size = 1024)

MethodPayloadSizeMeanErrorStdDevP95Allocated
Encrypt_Salsa2010241,895.6 ns25.27 ns28.09 ns1,940.0 ns0 B
Decrypt_Salsa2010241,887.3 ns21.79 ns25.09 ns1,928.4 ns0 B
Encrypt_Chacha2010241,127.3 ns265.28 ns305.50 ns1,419.2 ns0 B
Decrypt_Chacha2010241,301.6 ns59.30 ns68.29 ns1,334.3 ns0 B
Encrypt_Salsa20Poly130510244,526.5 ns64.45 ns74.22 ns4,583.9 ns0 B
Decrypt_Salsa20Poly130510244,606.4 ns12.49 ns14.39 ns4,623.0 ns0 B
Encrypt_Chacha20Poly130510242,695.9 ns59.62 ns68.66 ns2,743.3 ns0 B
Decrypt_Chacha20Poly130510242,736.3 ns60.69 ns69.89 ns2,788.0 ns0 B

Behind the design

  • Software-Efficient Stream Ciphers: Salsa20 and ChaCha20 perform encryption at near-hardware speeds. The state is maintained in stackalloc memory, ensuring zero allocations.
  • One-Pass AEAD: The combined ciphers with Poly1305 perform authentication and decryption in a single pass over the memory block, minimizing cache misses.

Handshake Protocol

Performance metrics for the cryptographic handshake phase, establishing session identity.

MethodMeanErrorStdDevP95Allocated
ComputeMasterSecret2.513 μs0.1719 μs0.1980 μs2.614 μs0 B
ComputeServerProof2.194 μs0.2906 μs0.3346 μs2.609 μs0 B
ComputeClientProof2.368 μs0.3165 μs0.3645 μs2.654 μs0 B
DeriveSessionKey2.619 μs0.0755 μs0.0869 μs2.675 μs0 B

Behind the design

  • Zero-Allocation Keys: High-cost key computations take ~2–2.6 μs each and run completely allocation-free (0 B), isolating cryptographic handshakes from garbage collection impacts.

Hashing & Cryptography

Comparison of cryptographic hashing, verification ciphers, and key derivation algorithms.

Hashing Performance (Payload Size = 64)

MethodPayloadSizeMeanErrorStdDevP95Allocated
Keccak256_Hash64605.3 ns11.16 ns12.85 ns615.0 ns0 B
HmacKeccak256_Compute642,518.4 ns45.27 ns52.13 ns2,553.1 ns0 B
Poly1305_Compute64111.5 ns0.95 ns1.09 ns112.3 ns0 B
Pbkdf2_Hash642,561,666.8 ns43,716.23 ns50,343.68 ns2,609,432.4 ns312 B
Pbkdf2_Verify642,548,772.0 ns39,314.36 ns45,274.48 ns2,590,398.3 ns256 B

Hashing Performance (Payload Size = 1024)

MethodPayloadSizeMeanErrorStdDevP95Allocated
Keccak256_Hash10244,862.0 ns64.07 ns71.22 ns4,967.1 ns0 B
HmacKeccak256_Compute10246,591.5 ns140.27 ns161.54 ns6,758.3 ns0 B
Poly1305_Compute1024888.9 ns57.31 ns66.00 ns940.5 ns0 B
Pbkdf2_Hash10242,545,073.2 ns49,667.27 ns57,196.90 ns2,608,114.0 ns312 B
Pbkdf2_Verify10242,552,527.7 ns49,817.62 ns57,370.04 ns2,601,772.5 ns256 B

Behind the design

  • Keccak Optimization: Our custom Keccak256 implementation hashes small structures in ~605 ns and 1KB structures in 4.86 μs without allocating memory.
  • PBKDF2 Overhead & Isolation: PBKDF2 is a secure key derivation function designed to be intentionally computationally expensive (taking ~2.5 ms per operation). Due to its CPU-bound nature, PBKDF2 checks are isolated from the networking hot path to prevent starvation of the listener thread pool.