Cryptography in Eryx

Eryx's cryptography libraries are split into two broad layers:

  1. High-level crypto, for the operations application code usually wants directly.
  2. Hazardous materials, for low-level cryptographic primitives and formats.

That distinction matters because cryptography is one of the easiest places to write code that appears correct, passes tests, and still fails in production. The higher-level APIs try to make the safe path short and obvious. The hazmat APIs remain available when you genuinely need protocol-level control, interoperability with an external system, or exact algorithm selection.

The High-Level Layer

The high-level layer is the API most applications should start with. It focuses on complete workflows rather than individual algorithms:

In practice, if you are trying to answer questions like:

then you probably want the high-level layer.

Start here: High-Level Crypto

The Hazmat Layer

The hazmat layer exposes the raw building blocks:

These modules are powerful, but they assume you know what you are doing. They are the right choice when you are implementing or interoperating with a protocol, reproducing an existing format, or composing several primitives into a scheme of your own.

Start here: Hazmat Crypto

A Practical Rule of Thumb

Prefer the highest-level API that solves your problem.

Use @eryx/crypto/password instead of calling Argon2 directly when storing passwords.

Use @eryx/crypto/secretbox instead of manually juggling ChaCha20-Poly1305 nonces and tags when you just want to encrypt data with a shared secret.

Reach for hazmat only when one of these is true: