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.
Functions
| 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. |
| createRandomBytes | - |
| createSlip21 | SLIP21. |
| decryptWithXChaCha20Poly1305 | Decrypts ciphertext with XChaCha20-Poly1305. |
| deriveSlip21Node | Derives a single node in the SLIP-21 hierarchical key derivation. |
| encryptWithXChaCha20Poly1305 | Encrypts plaintext with XChaCha20-Poly1305. |
| testCreateRandomBytes | Creates seeded random bytes for deterministic tests. |
Interfaces
| Interface | Description |
|---|---|
| DecryptWithXChaCha20Poly1305Error | Base interface for objects with a discriminant type property. |
| RandomBytes | - |
| RandomBytesDep | - |
| TimingSafeEqualDep | - |
Type Aliases
| Type Alias | Description |
|---|---|
| EncryptionKey | The encryption key for symmetric encryption. |
| Entropy16 | - |
| Entropy24 | - |
| Entropy32 | - |
| Entropy64 | - |
| 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. |
| XChaCha20Poly1305Ciphertext | Branded Uint8Array for XChaCha20-Poly1305 encryption. |
Variables
| Variable | Description |
|---|---|
| EncryptionKey | The encryption key for symmetric encryption. |
| Entropy16 | - |
| Entropy24 | - |
| Entropy32 | - |
| Entropy64 | - |
| XChaCha20Poly1305Ciphertext | Branded Uint8Array for XChaCha20-Poly1305 encryption. |
| xChaCha20Poly1305NonceLength | The nonce length for XChaCha20-Poly1305 encryption. |