# `Cartouche.Solana.Signer`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche/solana/signer.ex#L1)

GenServer that wraps Ed25519 signing backends for Solana.

Follows the same MFA (module, function, args) backend pattern as the
Ethereum `Cartouche.Signer`, but much simpler: no recovery bit brute-force,
no chain ID encoding.

Delegates to a backend module (e.g., `Cartouche.Solana.Signer.Ed25519` for
local keys, or `Cartouche.Solana.Signer.CloudKMS` for GCP KMS). Caches
the public key on first use.

## Examples

    # Start via supervisor or manually:
    {:ok, pid} = Cartouche.Solana.Signer.start_link(
      mfa: {Cartouche.Solana.Signer.Ed25519, :sign, [seed]},
      name: MySolSigner
    )

    # Sign a message:
    {:ok, signature} = Cartouche.Solana.Signer.sign(message, MySolSigner)

    # Get the signer's public key:
    pub_key = Cartouche.Solana.Signer.address(MySolSigner)

# `address`

```elixir
@spec address(GenServer.name()) :: &lt;&lt;_::256&gt;&gt;
```

Get the 32-byte public key (Solana address) for this signer.

## Examples

    iex> signer = Cartouche.Solana.Test.Signer.start_signer()
    iex> address = Cartouche.Solana.Signer.address(signer)
    iex> byte_size(address)
    32

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `sign`

```elixir
@spec sign(binary(), GenServer.name()) :: {:ok, &lt;&lt;_::512&gt;&gt;} | {:error, term()}
```

Sign raw message bytes. Returns a 64-byte Ed25519 signature.

## Examples

    iex> signer = Cartouche.Solana.Test.Signer.start_signer()
    iex> {:ok, sig} = Cartouche.Solana.Signer.sign("test", signer)
    iex> byte_size(sig)
    64

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts a new Solana signer process.

# `verify`

```elixir
@spec verify(binary(), &lt;&lt;_::512&gt;&gt;, &lt;&lt;_::256&gt;&gt;) :: boolean()
```

Verify an Ed25519 signature. Standalone function, no GenServer needed.

## Examples

    iex> seed = Base.decode16!("9D61B19DEFFD5A60BA844AF492EC2CC44449C5697B326919703BAC031CAE7F60")
    iex> pub = Base.decode16!("D75A980182B10AB7D54BFED3C964073A0EE172F3DAA62325AF021A68F707511A")
    iex> {:ok, sig} = Cartouche.Solana.Signer.Ed25519.sign("test", seed)
    iex> Cartouche.Solana.Signer.verify("test", sig, pub)
    true

---

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