ExWapp.Signal.Adapter (ExWapp v0.1.2)

Copy Markdown View Source

Pure Elixir Signal adapter.

Historically this project had both Rust NIF and Elixir implementations. To keep protocol debugging predictable, the adapter now exposes a single implementation: ExWapp.Signal.Session.

Summary

Functions

Creates a new session using X3DH key agreement.

Debug: dump a message's structure.

Decrypts a regular Signal message.

Decrypts a PreKeySignalMessage (initial message from new sender).

Decrypts a PreKeySignalMessage using an existing session.

Encrypts a message using the session.

Encrypts a first message (PreKeySignalMessage).

Generate a new Curve25519 key pair.

Generate a signed prekey with XEdDSA signature.

Returns info about the current implementation.

Types

impl()

@type impl() :: :elixir

Functions

create_session(local_identity, remote_bundle)

@spec create_session(map(), map()) :: {:ok, map(), binary()} | {:error, term()}

Creates a new session using X3DH key agreement.

debug_message(message)

@spec debug_message(binary()) :: String.t()

Debug: dump a message's structure.

decrypt(session, ciphertext)

@spec decrypt(map(), binary()) :: {:ok, binary(), map()} | {:error, term()}

Decrypts a regular Signal message.

decrypt_prekey_message(ciphertext, local_identity, local_prekeys)

@spec decrypt_prekey_message(binary(), map(), map()) ::
  {:ok, binary(), map()} | {:error, term()}

Decrypts a PreKeySignalMessage (initial message from new sender).

decrypt_prekey_message_with_session(session, ciphertext)

@spec decrypt_prekey_message_with_session(map(), binary()) ::
  {:ok, binary(), map()} | {:error, term()}

Decrypts a PreKeySignalMessage using an existing session.

encrypt(session, plaintext, opts \\ [])

@spec encrypt(map(), binary(), keyword()) :: {:ok, binary(), map()}

Encrypts a message using the session.

Options

  • :is_prekey - Whether to wrap in PreKeySignalMessage (default: false)
  • :bundle_info - Bundle info for PreKeySignalMessage (required if is_prekey)

Returns {:ok, ciphertext, updated_session}.

encrypt_prekey_message(session, plaintext, bundle_info)

@spec encrypt_prekey_message(map(), binary(), map()) :: {:ok, binary(), map()}

Encrypts a first message (PreKeySignalMessage).

Convenience wrapper for encrypt/3 with is_prekey: true.

generate_key_pair()

@spec generate_key_pair() :: {binary(), binary()}

Generate a new Curve25519 key pair.

generate_signed_prekey(identity_private)

@spec generate_signed_prekey(binary()) :: {binary(), binary(), binary()}

Generate a signed prekey with XEdDSA signature.

get_impl()

@spec get_impl() :: impl()

impl_module()

@spec impl_module() :: module()

info()

@spec info() :: map()

Returns info about the current implementation.

set_impl(atom)

@spec set_impl(:elixir | :native) :: :ok

verify_signature(public_key, message, signature)

@spec verify_signature(binary(), binary(), binary()) :: boolean()

Verify XEdDSA signature.