# `AshHooks.Custody.PublicKey`
[🔗](https://github.com/baselabs/ash_hooks/blob/v3.3.0/lib/ash_hooks/custody/public_key.ex#L1)

A pinned sender public key with its host-selected asymmetric algorithm.

Unlike `AshHooks.Custody.Key`, this value contains public verification
material and never calls a custodian. Providers receive this struct rather
than untyped bytes. HMAC verifiers refuse it with `KeyKindMismatch`.

`new/2` validates the key before a source is created or updated. Kinds are
`{:standard_webhooks, :v1a}` for a `whpk_` Ed25519 key, `:ed25519`,
`:rsa_pkcs1_sha256`, `:rsa_pkcs1_sha384`, `:rsa_pkcs1_sha512`,
`:rsa_pss_sha256`, `:rsa_pss_sha384`, `:rsa_pss_sha512`,
`:ecdsa_p256_sha256`, and `:ecdsa_p384_sha384`. The kind pins the digest,
RSA padding, and ECDSA curve as well as the key family.

# `kind`

```elixir
@type kind() ::
  {:standard_webhooks, :v1a}
  | :ed25519
  | :rsa_pkcs1_sha256
  | :rsa_pkcs1_sha384
  | :rsa_pkcs1_sha512
  | :rsa_pss_sha256
  | :rsa_pss_sha384
  | :rsa_pss_sha512
  | :ecdsa_p256_sha256
  | :ecdsa_p384_sha384
```

# `t`

```elixir
@type t() :: %AshHooks.Custody.PublicKey{key: term(), kind: kind()}
```

# `new`

```elixir
@spec new(term(), term()) :: {:ok, t()} | {:error, struct()}
```

Validates public verification material for one of the supported asymmetric
kinds listed in the module contract. Returns `{:ok, public_key}` or
`{:error, %AshHooks.Errors.Invalid.KeyKindMismatch{}}` when the kind or
material is invalid or does not match.

---

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