# `ExWapp.Signal.Adapter`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/signal/adapter.ex#L1)

Pure Elixir Signal adapter.

Historically this project had both Rust NIF and Elixir implementations.
To keep protocol debugging predictable, the adapter now exposes a single
implementation: `ExWapp.Signal.Session`.

# `impl`

```elixir
@type impl() :: :elixir
```

# `create_session`

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

Creates a new session using X3DH key agreement.

# `debug_message`

```elixir
@spec debug_message(binary()) :: String.t()
```

Debug: dump a message's structure.

# `decrypt`

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

Decrypts a regular Signal message.

# `decrypt_prekey_message`

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

Decrypts a PreKeySignalMessage (initial message from new sender).

# `decrypt_prekey_message_with_session`

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

Decrypts a PreKeySignalMessage using an existing session.

# `encrypt`

```elixir
@spec encrypt(map(), binary(), keyword()) :: {:ok, binary(), map()}
```

Encrypts a message using the session.

## Options
- `:is_prekey` - Whether to wrap in PreKeySignalMessage (default: false)
- `:bundle_info` - Bundle info for PreKeySignalMessage (required if is_prekey)

Returns `{:ok, ciphertext, updated_session}`.

# `encrypt_prekey_message`

```elixir
@spec encrypt_prekey_message(map(), binary(), map()) :: {:ok, binary(), map()}
```

Encrypts a first message (PreKeySignalMessage).

Convenience wrapper for `encrypt/3` with `is_prekey: true`.

# `generate_key_pair`

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

Generate a new Curve25519 key pair.

# `generate_signed_prekey`

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

Generate a signed prekey with XEdDSA signature.

# `get_impl`

```elixir
@spec get_impl() :: impl()
```

# `impl_module`

```elixir
@spec impl_module() :: module()
```

# `info`

```elixir
@spec info() :: map()
```

Returns info about the current implementation.

# `set_impl`

```elixir
@spec set_impl(:elixir | :native) :: :ok
```

# `verify_signature`

```elixir
@spec verify_signature(binary(), binary(), binary()) :: boolean()
```

Verify XEdDSA signature.

---

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