SignalProtocol.Session (libsignal_protocol v0.1.1)

View Source

Handles Signal Protocol sessions for secure messaging.

This module provides a high-level interface for managing Signal Protocol sessions, including session creation, message encryption, and decryption.

Summary

Functions

Creates a new session with the given local and remote identity keys.

Creates a new session and processes a pre-key bundle in one step.

Decrypts a message using the given session.

Encrypts a message using the given session.

Processes a pre-key bundle to establish a session.

Receives a message through a session, handling decryption.

Sends a message through a session, handling encryption.

Functions

create(local_identity_key, remote_identity_key)

Creates a new session with the given local and remote identity keys.

Parameters

  • local_identity_key - The local user's identity key
  • remote_identity_key - The remote user's identity key

Returns {:ok, session} on success, where session is a reference to the session state.

create_and_process_bundle(local_identity_key, remote_identity_key, bundle)

Creates a new session and processes a pre-key bundle in one step.

Parameters

  • local_identity_key - The local user's identity key
  • remote_identity_key - The remote user's identity key
  • bundle - The pre-key bundle to process

Returns {:ok, session} on success.

decrypt_message(session, ciphertext)

Decrypts a message using the given session.

Parameters

  • session - The session reference
  • ciphertext - The encrypted message to decrypt

Returns {:ok, plaintext} on success.

encrypt_message(session, message)

Encrypts a message using the given session.

Parameters

  • session - The session reference
  • message - The message to encrypt

Returns {:ok, ciphertext} on success.

process_pre_key_bundle(session, bundle)

Processes a pre-key bundle to establish a session.

Parameters

  • session - The session reference
  • bundle - The pre-key bundle to process

Returns :ok on success.

receive_message(session, ciphertext)

Receives a message through a session, handling decryption.

Parameters

  • session - The session reference
  • ciphertext - The encrypted message to receive

Returns {:ok, plaintext} on success.

send_message(session, message)

Sends a message through a session, handling encryption.

Parameters

  • session - The session reference
  • message - The message to send

Returns {:ok, ciphertext} on success.