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
@type one_time_prekey() :: %{id: pos_integer(), public: binary(), private: binary()}
@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() }
@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() }
@type signed_prekey() :: %{ id: pos_integer(), public: binary(), private: binary(), signature: binary() }
Functions
@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.