Amarula.Protocol.Signal.SessionStore (amarula v0.1.0)
View SourceStorage glue for the 1:1 Signal session cipher.
Two responsibilities:
- Build the
storemap thatSessionBuilder/SessionCipherneed — our identity keypair and prekey lookups — sourced from the auth creds map. - Persist
SessionRecords viaAmarula.Storage(the:sessionnamespace, keyed by signal address). Survives restart so ratchet state isn't lost.
Persistence is scoped to the connection: the conn (Amarula.Conn) supplies
the storage scope and name passed to every Amarula.Storage call.
Keys here are raw 32-byte X25519 (no 0x05 prefix); the cipher/DH handle wire prefixing where needed.
Summary
Functions
Build the cipher store from auth creds.
Load a SessionRecord for addr on conn, or nil if none saved.
Persist a SessionRecord for addr on conn.
Functions
Build the cipher store from auth creds.
creds must have signed_identity_key (%{public, private}), signed_pre_key
(%{key_pair: %{public, private}, key_id, ...}). One-time prekeys come from
creds.pre_keys (integer id => %{public, private}, populated by
Signal.PreKeys at upload time); when the id is unknown — e.g. already
consumed — load_pre_key returns nil and the responder X3DH falls back to
the 4-DH path (no a4), which libsignal supports.
@spec load_session(Amarula.Conn.t(), String.t()) :: map() | nil
Load a SessionRecord for addr on conn, or nil if none saved.
@spec store_session(Amarula.Conn.t(), String.t(), map()) :: :ok | {:error, term()}
Persist a SessionRecord for addr on conn.