[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Crypto](https://evolu.dev/docs/api-reference/common/Crypto) › decryptWithXChaCha20Poly1305

```ts
function decryptWithXChaCha20Poly1305(
  ciphertext: Uint8Array<ArrayBufferLike> &
    Brand<"XChaCha20Poly1305Ciphertext">,
  nonce: Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length24">,
  encryptionKey: Uint8Array<ArrayBufferLike> &
    Brand<"Entropy"> &
    Brand<"Length32"> &
    Brand<"EncryptionKey">,
): Result<Uint8Array<ArrayBufferLike>, DecryptWithXChaCha20Poly1305Error>;
```

Defined in: [packages/common/src/Crypto.ts:211](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Crypto.ts#L211)

Decrypts ciphertext with XChaCha20-Poly1305.

Requires the same nonce that was used during encryption. Returns a
[Result](https://evolu.dev/docs/api-reference/common/Result/type-aliases/Result) that may contain a decryption error if the ciphertext was
tampered with or the wrong key/nonce was used.

### Example

```ts
const result = decryptWithXChaCha20Poly1305(ciphertext, nonce, encryptionKey);
if (!result.ok) {
  // Handle decryption error
  return result;
}
const plaintext = result.value;
```