# `Apero.Crypto.Key`
[🔗](https://github.com/Lorenzo-SF/apero/blob/3.0.0/lib/apero/crypto/key.ex#L1)

Key derivation and asymmetric key generation utilities.

Provides:
  * Key derivation: PBKDF2, Argon2id
  * Key exchange: ECDH (X25519)
  * Asymmetric: RSA key generation

# `argon2id`

```elixir
@spec argon2id(binary(), binary(), keyword()) :: {:ok, binary()} | {:error, term()}
```

Derives a key using Argon2id (requires optional `argon2_elixir` dependency).

# `compute_ecdh_secret`

```elixir
@spec compute_ecdh_secret(binary(), binary()) :: {:ok, binary()} | :error
```

Computes a shared secret from your private key and peer's public key.

# `generate_ecdh_keypair`

```elixir
@spec generate_ecdh_keypair() :: {binary(), binary()}
```

Generates an X25519 key pair. Returns `{private_key, public_key}` (both raw binary).

# `generate_rsa_keypair`

```elixir
@spec generate_rsa_keypair() :: {:ok, {binary(), binary()}} | {:error, term()}
```

Generates an RSA key pair (2048-bit). Returns `{private_der, public_der}`.

# `pbkdf2`

```elixir
@spec pbkdf2(binary(), binary(), keyword()) :: binary()
```

Derives a key using PBKDF2-HMAC-SHA256.

---

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