# `OpenPayments.Types.JWK`
[🔗](https://github.com/interledger/open-payments-elixir/blob/v1.0.0/lib/open_payments/types/jwk.ex#L1)

An Ed25519 public JSON Web Key used by Open Payments.

`from_map/1` validates the shared schema's required fields and enum values.
An omitted `use` becomes nil; an explicit null is invalid. Additional JSON
metadata is preserved in `extensions`.

This public type rejects the private `d` parameter and excludes it from export,
including when a struct is manually modified. Its inspection omits extensions.
Private-key import belongs to the signing utilities.

Validation checks the schema's nonempty base64url alphabet for `x`. It does not
establish that the value decodes to a usable 32-byte Ed25519 key. Cryptographic
key validation and key selection are separate from decoding response data.

Struct literals can bypass validation. Call `validate/1` after constructing or
modifying a struct; `to_map/1` converts its shape without validating it.

# `t`

```elixir
@type t() :: %OpenPayments.Types.JWK{
  alg: String.t(),
  crv: String.t(),
  extensions: %{optional(String.t()) =&gt; term()},
  kid: String.t(),
  kty: String.t(),
  use: String.t() | nil,
  x: String.t()
}
```

# `from_map`

```elixir
@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}
```

Decodes and validates a public JWK JSON object.

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts a public JWK to JSON fields, excluding private key material.

# `validate`

```elixir
@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}
```

Validates a public JWK struct, treating nil use as omitted.

---

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