Amarula.Protocol.Signal.Types (amarula v0.1.0)

View Source

Core Signal Protocol types and data structures.

Defines all the data structures used in the Signal Protocol implementation, including keys, sessions, addresses, and encryption options.

Summary

Types

decrypt_group_opts()

@type decrypt_group_opts() :: %{
  group: String.t(),
  author_jid: String.t(),
  msg: binary()
}

decrypt_opts()

@type decrypt_opts() :: %{jid: String.t(), type: message_type(), ciphertext: binary()}

e2e_session()

@type e2e_session() :: %{
  registration_id: non_neg_integer(),
  identity_key: binary(),
  signed_pre_key: signed_pre_key(),
  pre_key: pre_key()
}

encrypt_group_opts()

@type encrypt_group_opts() :: %{group: String.t(), data: binary(), me_id: String.t()}

encrypt_group_result()

@type encrypt_group_result() :: %{
  sender_key_distribution_message: binary(),
  ciphertext: binary()
}

encrypt_opts()

@type encrypt_opts() :: %{jid: String.t(), data: binary()}

encrypt_result()

@type encrypt_result() :: %{type: message_type(), ciphertext: binary()}

key_pair()

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

key_store_opts()

@type key_store_opts() :: %{
  table_name: atom(),
  cleanup_interval: non_neg_integer(),
  max_size: non_neg_integer()
}

key_store_result()

@type key_store_result() :: %{
  success: boolean(),
  data: any() | nil,
  error: String.t() | nil
}

key_type()

@type key_type() :: :session | :prekey | :identity | :sender_key

lid_mapping()

@type lid_mapping() :: %{pn: String.t(), lid: String.t()}

lid_mapping_result()

@type lid_mapping_result() :: %{mappings: [lid_mapping()], missing: [String.t()]}

message_type()

@type message_type() :: :pkmsg | :msg

migration_result()

@type migration_result() :: %{
  migrated: non_neg_integer(),
  skipped: non_neg_integer(),
  total: non_neg_integer()
}

pre_key()

@type pre_key() :: %{key_id: non_neg_integer(), public_key: binary()}

protocol_address()

@type protocol_address() :: %{name: String.t(), device_id: non_neg_integer()}

session_info()

@type session_info() :: %{
  jid: String.t(),
  state: session_state(),
  created_at: DateTime.t(),
  last_used: DateTime.t() | nil,
  message_count: non_neg_integer()
}

session_state()

@type session_state() :: :active | :inactive | :pending | :expired

signal_config()

@type signal_config() :: %{
  key_store: key_store_opts(),
  session_timeout: non_neg_integer(),
  max_sessions: non_neg_integer(),
  enable_lid_mapping: boolean(),
  cache_ttl: non_neg_integer()
}

signal_creds()

@type signal_creds() :: %{
  signed_identity_key: key_pair(),
  signed_pre_key: signed_key_pair(),
  registration_id: non_neg_integer()
}

signal_error()

@type signal_error() :: %{type: atom(), message: String.t(), details: map() | nil}

signal_identity()

@type signal_identity() :: %{identifier: protocol_address(), identifier_key: binary()}

signed_key_pair()

@type signed_key_pair() :: %{
  key_pair: key_pair(),
  signature: binary(),
  key_id: non_neg_integer(),
  timestamp_s: non_neg_integer() | nil
}

signed_pre_key()

@type signed_pre_key() :: pre_key() | %{signature: binary()}

validation_result()

@type validation_result() :: %{exists: boolean(), reason: String.t() | nil}