[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/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](https://evolu.dev/docs/api-reference/common/Crypto/functions/createPadmePaddedLength)           | Returns the PADMÉ padded length for a given input length.          |
| [createPadmePadding](https://evolu.dev/docs/api-reference/common/Crypto/functions/createPadmePadding)                     | Creates a PADMÉ padding array of zeros for the given input length. |
| [createRandomBytes](https://evolu.dev/docs/api-reference/common/Crypto/functions/createRandomBytes)                       | -                                                                  |
| [createSlip21](https://evolu.dev/docs/api-reference/common/Crypto/functions/createSlip21)                                 | SLIP21.                                                            |
| [decryptWithXChaCha20Poly1305](https://evolu.dev/docs/api-reference/common/Crypto/functions/decryptWithXChaCha20Poly1305) | Decrypts ciphertext with XChaCha20-Poly1305.                       |
| [deriveSlip21Node](https://evolu.dev/docs/api-reference/common/Crypto/functions/deriveSlip21Node)                         | Derives a single node in the SLIP-21 hierarchical key derivation.  |
| [encryptWithXChaCha20Poly1305](https://evolu.dev/docs/api-reference/common/Crypto/functions/encryptWithXChaCha20Poly1305) | Encrypts plaintext with XChaCha20-Poly1305.                        |
| [testCreateRandomBytes](https://evolu.dev/docs/api-reference/common/Crypto/functions/testCreateRandomBytes)               | Creates seeded random bytes for deterministic tests.               |

## Interfaces

| Interface                                                                                                               | Description                                                     |
| ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [DecryptWithXChaCha20Poly1305Error](https://evolu.dev/docs/api-reference/common/Crypto/interfaces/DecryptWithXChaCha20Poly1305Error) | Base interface for objects with a discriminant `type` property. |
| [RandomBytes](https://evolu.dev/docs/api-reference/common/Crypto/interfaces/RandomBytes)                                             | -                                                               |
| [RandomBytesDep](https://evolu.dev/docs/api-reference/common/Crypto/interfaces/RandomBytesDep)                                       | -                                                               |
| [TimingSafeEqualDep](https://evolu.dev/docs/api-reference/common/Crypto/interfaces/TimingSafeEqualDep)                               | -                                                               |

## Type Aliases

| Type Alias                                                                                                    | Description                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [EncryptionKey](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/EncryptionKey)                             | The encryption key for symmetric encryption.                                                                                                                      |
| [Entropy16](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/Entropy16)                                     | -                                                                                                                                                                 |
| [Entropy24](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/Entropy24)                                     | -                                                                                                                                                                 |
| [Entropy32](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/Entropy32)                                     | -                                                                                                                                                                 |
| [Entropy64](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/Entropy64)                                     | -                                                                                                                                                                 |
| [TimingSafeEqual](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/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](https://evolu.dev/docs/api-reference/common/Crypto/type-aliases/XChaCha20Poly1305Ciphertext) | Branded Uint8Array for XChaCha20-Poly1305 encryption.                                                                                                             |

## Variables

| Variable                                                                                                     | Description                                           |
| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
| [EncryptionKey](https://evolu.dev/docs/api-reference/common/Crypto/variables/EncryptionKey)                               | The encryption key for symmetric encryption.          |
| [Entropy16](https://evolu.dev/docs/api-reference/common/Crypto/variables/Entropy16)                                       | -                                                     |
| [Entropy24](https://evolu.dev/docs/api-reference/common/Crypto/variables/Entropy24)                                       | -                                                     |
| [Entropy32](https://evolu.dev/docs/api-reference/common/Crypto/variables/Entropy32)                                       | -                                                     |
| [Entropy64](https://evolu.dev/docs/api-reference/common/Crypto/variables/Entropy64)                                       | -                                                     |
| [XChaCha20Poly1305Ciphertext](https://evolu.dev/docs/api-reference/common/Crypto/variables/XChaCha20Poly1305Ciphertext)   | Branded Uint8Array for XChaCha20-Poly1305 encryption. |
| [xChaCha20Poly1305NonceLength](https://evolu.dev/docs/api-reference/common/Crypto/variables/xChaCha20Poly1305NonceLength) | The nonce length for XChaCha20-Poly1305 encryption.   |