Skip to content

Struct crypto::voice::GroupKeys

zaun_community_protocol::crypto::voice::GroupKeys · Struct

pub struct GroupKeys { … }

A participant’s key state for one voice session.

pub fn new(member_key: &SecretKey, community_id: CommunityId, channel_id: ChannelId, member_id: MemberId, min_suite: u8, created_at: u64) -> Result<Self, VoiceError>

Starts a voice session: a fresh voice session id and X-Wing key pair, and the key package signed by member_key.

VoiceError::Rng or VoiceError::Signed.

pub const fn voice_session(&self) -> VoiceSessionId

This participant’s voice session.

pub const fn key_package(&self) -> &SignedKeyPackage

This participant’s signed key package (send its SignedKeyPackage::to_wire).

pub const fn needs_rekey(&self) -> bool

Whether the peer set changed since the last Self::rekey.

pub fn peers(&self) -> impl Iterator<Item = (VoiceSessionId, MemberId)> + '_

The voice sessions of the current peers.

pub fn add_peer(&mut self, member_id: MemberId, member_key: &PublicKey, package_wire: &[u8]) -> Result<VoiceSessionId, VoiceError>

Verifies and adds a peer’s key package. member_key is the roster’s key for member_id. Re-adding the same package is a no-op.

As KeyPackage::verify; VoiceError::Recipients beyond MAX_RECIPIENTS peers; VoiceError::KidCollision when its KID tag equals another participant’s (the newer participant rejoins with a new voice session); VoiceError::Mismatch for a different package under a known session.

pub fn remove_peer(&mut self, session: &VoiceSessionId) -> bool

Forgets a peer and its keys. Returns whether it was known.

pub fn rekey(&mut self, member_key: &SecretKey, created_at: u64) -> Result<Rekey, VoiceError>

Makes the next epoch: a fresh base key wrapped to every current peer and the signed sender-keys message. The new key seals only after Self::activate.

VoiceError::Exhausted after 2^32 epochs; VoiceError::Rng; HPKE or signing failures.

pub fn activate(&mut self) -> bool

Switches sealing to the newest epoch. Returns whether there was one waiting.

pub fn seal(&mut self, metadata: &[u8], frame: &[u8]) -> Result<Vec<u8>, VoiceError>

Seals one of this participant’s frames under the active epoch.

VoiceError::NoSenderKey before the first activation; VoiceError::Exhausted.

pub fn accept_sender_keys(&mut self, from: &VoiceSessionId, sender_keys_wire: &[u8], wrapped: &[u8]) -> Result<u32, VoiceError>

Installs a peer’s epoch key: verifies the sender-keys message under the peer’s member key, checks that wrapped is the key it signed for this participant, opens it, and keeps the peer’s previous epoch for frames still in flight.

VoiceError::UnknownPeer, verification errors, VoiceError::NotARecipient, VoiceError::WrappedHash, VoiceError::StaleEpoch or VoiceError::Unwrap.

pub fn open(&mut self, metadata: &[u8], frame: &[u8]) -> Result<(VoiceSessionId, Vec<u8>), VoiceError>

Opens a frame from whichever peer’s KID it carries.

VoiceError::Header, VoiceError::UnknownKid, VoiceError::Replay or VoiceError::Open.

pub fn open_from(&mut self, from: &VoiceSessionId, metadata: &[u8], frame: &[u8]) -> Result<Vec<u8>, VoiceError>

Opens a frame that the transport says came from from; another peer’s KID is refused.

As Self::open, and VoiceError::UnknownPeer.

Debug

Full rustdoc page