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

Manages Signal protocol key material and session state.

The WhatsApp Web stack uses X3DH for session setup and the Double Ratchet
for transport messages. This module generates the initial identity and
pre-keys that must be published to the server and returns a structure that
can be persisted by the store backend.

# `identity_key`

```elixir
@type identity_key() :: %{public: binary(), private: binary()}
```

# `one_time_prekey`

```elixir
@type one_time_prekey() :: %{id: pos_integer(), public: binary(), private: binary()}
```

# `signal_info`

```elixir
@type signal_info() :: %{
  registration_id: pos_integer(),
  device_id: non_neg_integer(),
  identity_key: binary(),
  signed_prekey: %{id: pos_integer(), public: binary(), signature: binary()},
  prekey: %{id: pos_integer(), public: binary()},
  bundle: map()
}
```

# `signal_state`

```elixir
@type signal_state() :: %{
  identity_key: identity_key(),
  registration_id: pos_integer(),
  device_id: non_neg_integer(),
  signed_prekeys: %{optional(pos_integer()) =&gt; signed_prekey()},
  prekeys: %{optional(pos_integer()) =&gt; one_time_prekey()},
  next_prekey_id: pos_integer(),
  sessions: map(),
  updated_at: integer()
}
```

# `signed_prekey`

```elixir
@type signed_prekey() :: %{
  id: pos_integer(),
  public: binary(),
  private: binary(),
  signature: binary()
}
```

# `bootstrap`

```elixir
@spec bootstrap(map()) :: {:ok, signal_info(), signal_state()} | {:error, term()}
```

Initialises local identity and pre-key material.

Returns a tuple containing the published bundle information together with the
internal state that should be persisted.

---

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