Amarula.Protocol.Signal.Group.SenderKeyMessage (amarula v0.1.0)

View Source

Sender key message for group encryption, ported from src/Signal/Group/sender-key-message.ts.

Wire format: [version byte][Proto.SenderKeyMessage][64-byte XEd25519 sig] where version = (3 << 4) | 3 = 0x33 and the signature is XEd25519 (Curve25519 keys, same scheme as the identity key) over version + protobuf.

Summary

Functions

Creates a SenderKeyMessage from serialized bytes.

Gets the ciphertext.

Gets the iteration.

Gets the message type.

Creates a new SenderKeyMessage, signing with the Curve25519 private signature_key.

Serializes the message to binary.

Verifies the XEd25519 signature against the Curve25519 public signature_key (raw 32 bytes or 0x05-prefixed 33 bytes).

Types

t()

@type t() :: %Amarula.Protocol.Signal.Group.SenderKeyMessage{
  ciphertext: binary(),
  iteration: non_neg_integer(),
  key_id: non_neg_integer(),
  message_version: non_neg_integer(),
  serialized: binary(),
  signature: binary()
}

Functions

from_serialized(serialized)

@spec from_serialized(binary()) :: {:ok, t()} | {:error, String.t()}

Creates a SenderKeyMessage from serialized bytes.

get_ciphertext(sender_key_message)

@spec get_ciphertext(t()) :: binary()

Gets the ciphertext.

get_iteration(sender_key_message)

@spec get_iteration(t()) :: non_neg_integer()

Gets the iteration.

get_key_id(sender_key_message)

@spec get_key_id(t()) :: non_neg_integer()

Gets the key ID.

get_type(_)

@spec get_type(t()) :: non_neg_integer()

Gets the message type.

new(key_id, iteration, ciphertext, signature_key)

@spec new(non_neg_integer(), non_neg_integer(), binary(), binary()) :: t()

Creates a new SenderKeyMessage, signing with the Curve25519 private signature_key.

serialize(sender_key_message)

@spec serialize(t()) :: binary()

Serializes the message to binary.

verify_signature(sender_key_message, signature_key)

@spec verify_signature(t(), binary()) :: :ok | {:error, String.t()}

Verifies the XEd25519 signature against the Curve25519 public signature_key (raw 32 bytes or 0x05-prefixed 33 bytes).