# `Decibel.DecryptionError`
[🔗](https://github.com/ausimian/decibel/blob/1.2.1/lib/decibel/decryption_error.ex#L1)

Raised when a peer message cannot be decrypted or processed safely.

The `:reason` field is the stable machine-readable failure contract:

- `:truncated` means a required public-key field or authentication tag was
  incomplete.
- `:authentication_failed` means AEAD verification rejected the ciphertext.
- `:invalid_public_key` means the peer supplied a public key rejected by the
  selected DH function.

All reasons use the message `"Decryption failed"` so backend details and peer
data are not exposed.

If the failure occurs during the handshake phase, the `:remote_keys`
field contains any remote public keys processed before the failure. Failed
operations leave the session state and cipher nonce unchanged.

# `reason`

```elixir
@type reason() :: :truncated | :authentication_failed | :invalid_public_key
```

The reason a peer message could not be processed.

# `t`

```elixir
@type t() :: %Decibel.DecryptionError{
  __exception__: true,
  message: String.t(),
  reason: reason(),
  remote_keys: [] | [re: binary() | nil, rs: binary() | nil]
}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
