API reference › @evolu/common › Crypto
Cryptographic utilities.
Type-safe cryptographic operations including random bytes generation, SLIP21 key derivation, XChaCha20-Poly1305 symmetric encryption, PADMÉ padding, and timing-safe comparisons.
Random bytes
| Name | Description |
|---|---|
| RandomBytes | Cryptographically secure random bytes with length-branded results. |
| RandomBytesDep | Dependency wrapper for RandomBytes. |
| Entropy16 | Cryptographic entropy of exactly 16 bytes. |
| Entropy24 | Cryptographic entropy of exactly 24 bytes. |
| Entropy32 | Cryptographic entropy of exactly 32 bytes. |
| Entropy64 | Cryptographic entropy of exactly 64 bytes. |
| Entropy16 | Cryptographic entropy of exactly 16 bytes. |
| Entropy24 | Cryptographic entropy of exactly 24 bytes. |
| Entropy32 | Cryptographic entropy of exactly 32 bytes. |
| Entropy64 | Cryptographic entropy of exactly 64 bytes. |
| createRandomBytes | Creates RandomBytes backed by the platform's secure random number generator. |
Key derivation
| Function | Description |
|---|---|
| createSlip21 | SLIP21. |
| deriveSlip21Node | Derives a single node in the SLIP-21 hierarchical key derivation. |
Encryption
| Name | Description |
|---|---|
| DecryptWithXChaCha20Poly1305Error | Error returned by decryptWithXChaCha20Poly1305 when decryption fails. |
| EncryptionKey | The encryption key for symmetric encryption. |
| XChaCha20Poly1305Ciphertext | Branded Uint8Array for XChaCha20-Poly1305 encryption. |
| EncryptionKey | The encryption key for symmetric encryption. |
| XChaCha20Poly1305Ciphertext | Branded Uint8Array for XChaCha20-Poly1305 encryption. |
| xChaCha20Poly1305NonceLength | The nonce length for XChaCha20-Poly1305 encryption. |
| decryptWithXChaCha20Poly1305 | Decrypts ciphertext with XChaCha20-Poly1305. |
| encryptWithXChaCha20Poly1305 | Encrypts plaintext with XChaCha20-Poly1305. |
Padding
| Function | Description |
|---|---|
| createPadmePaddedLength | Returns the PADMÉ padded length for a given input length. |
| createPadmePadding | Creates a PADMÉ padding array of zeros for the given input length. |
Comparison
| Name | Description |
|---|---|
| TimingSafeEqualDep | Dependency wrapper for TimingSafeEqual. |
| TimingSafeEqual | Performs a timing-safe comparison of two Uint8Arrays. Returns true if they are equal, false otherwise. Takes constant time regardless of where the arrays differ. |
Testing
| Function | Description |
|---|---|
| testCreateRandomBytes | Creates seeded random bytes for deterministic tests. |