# `ReqDPoP.Key`
[🔗](https://github.com/XukuLLC/req_dpop/blob/v0.8.0/lib/req_dpop/key.ex#L1)

Helpers for DPoP signing keys.

Production clients should persist their DPoP key when they need stable
sender binding across process restarts.

`inspect/1` shows only the algorithm, never key material.

# `alg`

```elixir
@type alg() :: :es256 | :rs256
```

# `t`

```elixir
@type t() :: %ReqDPoP.Key{alg: alg(), jwk: JOSE.JWK.t()}
```

# `export`

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

Exports the private JWK as a map.

# `generate`

```elixir
@spec generate(alg()) :: t()
```

Generates a private signing key for `:es256` or `:rs256`.

# `jose_jwk`

```elixir
@spec jose_jwk(t()) :: JOSE.JWK.t()
```

Returns the underlying `JOSE.JWK`.

# `load!`

```elixir
@spec load!(t() | JOSE.JWK.t() | map()) :: t()
```

Loads a `ReqDPoP.Key` from a key struct, `JOSE.JWK`, or JWK map.

The key must be a complete private signing key: a P-256 EC key with 32-byte
`x`, `y`, and `d`, or an RSA key of at least 2048 bits with `n`, `e`, and
`d`. A JWK that carries `use` or `key_ops` (RFC 7517 sections 4.2 and 4.3)
must allow signing: `use` must be `"sig"`, and `key_ops` must be a list of
strings that contains `"sign"`. A key with neither member is accepted.
Anything else raises `ReqDPoP.Error` with reason `:invalid_key` or
`:unsupported_key`. Error messages never include key material.

# `proof_jwk`

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

Returns the public JWK placed in the proof `jwk` header.

Only the RFC 7638 thumbprint members are included: `crv`, `kty`, `x`, and
`y` for EC keys; `e`, `kty`, and `n` for RSA keys. Any other member of a
loaded JWK map stays out of the proof, so application-specific fields never
travel with it.

# `public_jwk`

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

Exports the public JWK as a map.

The map keeps every public member of the loaded JWK, such as `kid`, except
`key_ops`: the private key's operations (`sign`) do not describe what its
public half may do. The proof header uses `proof_jwk/1` instead.

# `thumbprint`

```elixir
@spec thumbprint(t() | JOSE.JWK.t() | map()) :: binary()
```

Returns the RFC 7638 SHA-256 JWK thumbprint, base64url unpadded.

Accepts public keys as well as private ones.

---

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