# `AshVault.Calculations.Decrypt`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/ash_vault/calculations/decrypt.ex#L1)

Decrypts the `encrypted_<field>` attribute back into a value of the original type.

`load/3` returning `[:"encrypted_<field>"]` is the *entire* dependency declaration. Ash
then auto-selects that attribute even though it is `public?: false` — `ensure_selected/2`
does not consult `public?` — records it in `query.context[:private][:depended_on_fields]`,
and strips it from the returned record, so ciphertext never leaks into results the caller
did not ask for.

## Errors are values

This calculation returns `{:error, %AshVault.Errors.*{}}` and never raises. That is a
deliberate departure from ash_cloak, which raises throughout its crypto path because
Cloak's API is bang-only. AshVault's errors are Splode errors with `class: :invalid`, so
Ash wraps them correctly and a destroyed tenant comes out of `Ash.read/2` as a clean
`AshVault.Errors.KeyDestroyed` rather than a 500.

It never returns `:unknown` either — to Ash that means "fall back to the data layer",
which for an encrypted field would silently produce ciphertext or nil.

## Field policies

A field policy denying the backing attribute makes `Map.get/2` return
`%Ash.ForbiddenField{}`, which is passed through untouched. AshVault does not
re-implement authorization: if a read reaches this calculation, Ash already authorized it.

# `describe`

# `has_calculate?`

# `has_expression?`

# `init`

# `strict_loads?`

---

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