# `AshVault.Errors.InvalidMac`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/ash_vault/errors.ex#L433)

Raised by `verify_mac!` when a tag does not verify.

The key version was found, the scope is not destroyed and the provider answered: the
tag is simply not the tag for this data, under this context (scope, resource, field)
and this key version. Causes are a forged or tampered tag, tampered data, a tag
replayed from another scope, resource or field, or a tag paired with the wrong key
version.

It is deliberately distinct from the three answers that are *not* "the tag is wrong":

  * `AshVault.Errors.KeyDestroyed` — the scope was crypto-erased; every tag it issued is
    revoked, permanently
  * `AshVault.Errors.KeyNotFound` — the claimed key version does not exist
  * `AshVault.Errors.ProviderUnavailable` — the provider could not answer; retry

The struct carries neither the tag nor the data. A tag is a bearer credential, and Ash
logs and reports errors verbatim.

# `exception`

```elixir
@spec exception(opts :: Keyword.t()) :: %AshVault.Errors.InvalidMac{
  __exception__: true,
  bread_crumbs: term(),
  class: term(),
  field: term(),
  key_version: term(),
  path: term(),
  resource: term(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}
```

Create an `Elixir.AshVault.Errors.InvalidMac` without raising it.

## Keys

- :resource
- :field
- :key_version

---

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