ExWapp.Signal (ExWapp v0.1.2)

Copy Markdown View Source

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.

Summary

Functions

Initialises local identity and pre-key material.

Types

identity_key()

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

one_time_prekey()

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

signal_info()

@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()

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

signed_prekey()

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

Functions

bootstrap(params)

@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.