Skip to main content

GroupKeys

Struct GroupKeys 

Source
pub struct GroupKeys { /* private fields */ }
Expand description

A participant’s key state for one voice session.

Implementations§

Source§

impl GroupKeys

Source

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.

§Errors

VoiceError::Rng or VoiceError::Signed.

Source

pub const fn voice_session(&self) -> VoiceSessionId

This participant’s voice session.

Source

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

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

Source

pub const fn needs_rekey(&self) -> bool

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

Source

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

The voice sessions of the current peers.

Source

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.

§Errors

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.

Source

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

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

Source

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.

§Errors

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

Source

pub fn activate(&mut self) -> bool

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

Source

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

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

§Errors

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

Source

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.

§Errors

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

Source

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

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

§Errors

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

Source

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.

§Errors

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

Trait Implementations§

Source§

impl Debug for GroupKeys

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.