pub struct GroupKeys { /* private fields */ }Expand description
A participant’s key state for one voice session.
Implementations§
Source§impl GroupKeys
impl GroupKeys
Sourcepub fn new(
member_key: &SecretKey,
community_id: CommunityId,
channel_id: ChannelId,
member_id: MemberId,
min_suite: u8,
created_at: u64,
) -> Result<Self, VoiceError>
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
Sourcepub const fn voice_session(&self) -> VoiceSessionId
pub const fn voice_session(&self) -> VoiceSessionId
This participant’s voice session.
Sourcepub const fn key_package(&self) -> &SignedKeyPackage
pub const fn key_package(&self) -> &SignedKeyPackage
This participant’s signed key package (send its SignedKeyPackage::to_wire).
Sourcepub const fn needs_rekey(&self) -> bool
pub const fn needs_rekey(&self) -> bool
Whether the peer set changed since the last Self::rekey.
Sourcepub fn peers(&self) -> impl Iterator<Item = (VoiceSessionId, MemberId)> + '_
pub fn peers(&self) -> impl Iterator<Item = (VoiceSessionId, MemberId)> + '_
The voice sessions of the current peers.
Sourcepub fn add_peer(
&mut self,
member_id: MemberId,
member_key: &PublicKey,
package_wire: &[u8],
) -> Result<VoiceSessionId, VoiceError>
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.
Sourcepub fn remove_peer(&mut self, session: &VoiceSessionId) -> bool
pub fn remove_peer(&mut self, session: &VoiceSessionId) -> bool
Forgets a peer and its keys. Returns whether it was known.
Sourcepub fn rekey(
&mut self,
member_key: &SecretKey,
created_at: u64,
) -> Result<Rekey, VoiceError>
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.
Sourcepub fn activate(&mut self) -> bool
pub fn activate(&mut self) -> bool
Switches sealing to the newest epoch. Returns whether there was one waiting.
Sourcepub fn seal(
&mut self,
metadata: &[u8],
frame: &[u8],
) -> Result<Vec<u8>, VoiceError>
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.
Sourcepub fn accept_sender_keys(
&mut self,
from: &VoiceSessionId,
sender_keys_wire: &[u8],
wrapped: &[u8],
) -> Result<u32, VoiceError>
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.
Sourcepub fn open(
&mut self,
metadata: &[u8],
frame: &[u8],
) -> Result<(VoiceSessionId, Vec<u8>), VoiceError>
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.
Sourcepub fn open_from(
&mut self,
from: &VoiceSessionId,
metadata: &[u8],
frame: &[u8],
) -> Result<Vec<u8>, VoiceError>
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.