# `X402.Signer.SolanaKey`
[🔗](https://github.com/cardotrejos/x402/blob/v0.9.0/lib/x402/signer/solana_key.ex#L1)

`X402.Signer` backed by a raw Ed25519 private key held in memory.

Signs Solana transaction message bytes through OTP's `:crypto` (EdDSA on
the `ed25519` curve) — no extra dependencies. `new/1` accepts:

* a raw 32-byte Ed25519 seed
* a 64-byte Solana keypair (`seed <> public_key`, the `solana-keygen`
  format) — the embedded public key is checked against the derived one
* the Base64 or Base58 encoding of either

The struct redacts the private key when inspected, but the key still
lives in process memory — prefer an external signer implementation (KMS,
hardware wallet) for production payers holding significant funds.

## Examples

    {:ok, signer} = X402.Signer.SolanaKey.new(:crypto.strong_rand_bytes(32))
    {:ok, address} = X402.Signer.SolanaKey.address(signer)

# `t`

```elixir
@type t() :: %X402.Signer.SolanaKey{address: String.t(), seed: binary()}
```

A local Ed25519 signing key with its derived Solana address.

# `address`
*since 0.6.0* 

```elixir
@spec address(t()) :: {:ok, String.t()}
```

Returns the Base58 Solana address derived from the private key.

# `new`
*since 0.6.0* 

```elixir
@spec new(binary()) :: {:ok, t()} | {:error, :invalid_private_key}
```

Builds a signer from an Ed25519 seed or Solana keypair.

Returns `{:error, :invalid_private_key}` for malformed keys and for
64-byte keypairs whose public half does not match the seed.

## Examples

    iex> {:ok, signer} = X402.Signer.SolanaKey.new(:binary.copy(<<1>>, 32))
    iex> signer.address
    "AKnL4NNf3DGWZJS6cPknBuEGnVsV4A4m5tgebLHaRSZ9"

    iex> X402.Signer.SolanaKey.new("not a key")
    {:error, :invalid_private_key}

# `sign_ed25519`
*since 0.6.0* 

```elixir
@spec sign_ed25519(t(), binary()) :: {:ok, X402.Signer.ed25519_signature()}
```

Signs `message` with the local Ed25519 key.

Ed25519 signing is deterministic (RFC 8032), so the same key and message
always produce the same 64-byte signature.

---

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