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

View Source

Represents a sender key record containing multiple sender key states.

A sender key record can contain up to 5 sender key states, allowing for key rotation and backward compatibility.

Summary

Functions

Adds a sender key state to the record.

Checks if the record is empty.

Creates a SenderKeyRecord from serialized data.

Gets the first (most recent) sender key state.

Gets the sender key state with the given key ID.

Creates a new empty SenderKeyRecord.

Serializes the record to a list of maps.

Gets the number of sender key states in the record.

Updates an existing sender key state in the record. If the state doesn't exist, adds it as a new state.

Types

t()

@type t() :: %Amarula.Protocol.Signal.Group.SenderKeyRecord{
  sender_key_states: [Amarula.Protocol.Signal.Group.SenderKeyState.t()]
}

Functions

add_sender_key_state(record, new_state)

@spec add_sender_key_state(t(), Amarula.Protocol.Signal.Group.SenderKeyState.t()) ::
  t()

Adds a sender key state to the record.

empty?(sender_key_record)

@spec empty?(t()) :: boolean()

Checks if the record is empty.

from_serialized(serialized_states)

@spec from_serialized([map()]) :: t()

Creates a SenderKeyRecord from serialized data.

get_sender_key_state(sender_key_record)

@spec get_sender_key_state(t()) ::
  {:ok, Amarula.Protocol.Signal.Group.SenderKeyState.t()} | {:error, String.t()}

Gets the first (most recent) sender key state.

get_sender_key_state(sender_key_record, key_id)

@spec get_sender_key_state(t(), non_neg_integer()) ::
  {:ok, Amarula.Protocol.Signal.Group.SenderKeyState.t()} | {:error, String.t()}

Gets the sender key state with the given key ID.

new()

@spec new() :: t()

Creates a new empty SenderKeyRecord.

serialize(sender_key_record)

@spec serialize(t()) :: [map()]

Serializes the record to a list of maps.

state_count(sender_key_record)

@spec state_count(t()) :: non_neg_integer()

Gets the number of sender key states in the record.

update_sender_key_state(record, updated_state)

@spec update_sender_key_state(t(), Amarula.Protocol.Signal.Group.SenderKeyState.t()) ::
  t()

Updates an existing sender key state in the record. If the state doesn't exist, adds it as a new state.