pub fn into_key_received(
        self,
        event: &mut ToDeviceEvent<KeyEventContent>,
    ) -> Result<SasState<KeyReceived>, SasState<Canceled>> {
        self.check_event(&event.sender, &event.content.transaction_id)
            .map_err(|c| self.clone().cancel(c))?;

        let utility = OlmUtility::new();
        let commitment = utility.sha256_utf8_msg(&format!(
            "{}{}",
            event.content.key, self.state.json_start_content
        ));

        if self.state.commitment != commitment {
            Err(self.cancel(CancelCode::InvalidMessage))
        } else {
            let their_pubkey = mem::take(&mut event.content.key);

            self.inner
                .lock()
                .unwrap()
                .set_their_public_key(their_pubkey.clone())
                .expect("Can't set public key");

            Ok(SasState {
                inner: self.inner,
                ids: self.ids,
                verification_flow_id: self.verification_flow_id,
                creation_time: self.creation_time,
                last_event_time: self.last_event_time,
                state: Arc::new(KeyReceived {
                    their_pubkey,
                    we_started: true,
                    accepted_protocols: self.state.accepted_protocols.clone(),
                }),
            })
        }
    }
/// Receive a m.key.verification.key event, changing the state into
/// a `KeyReceived` one
///
/// # Arguments
///
/// * `event` - The m.key.verification.key event that was sent to us by
/// the other side. The event will be modified so it doesn't contain any key
/// anymore.
Receive a m.key.verification.key event, changing the state into
a `KeyReceived` one
Receive a m . key . verification . key event changing the state into a ` KeyReceived ` one
pub fn into_key_received(
        self,
        event: &mut ToDeviceEvent<KeyEventContent>,
    ) -> Result<SasState<KeyReceived>, SasState<Canceled>> {
        self.check_event(&event.sender, &event.content.transaction_id)
            .map_err(|c| self.clone().cancel(c))?;
        let utility = OlmUtility::new();
        let commitment = utility.sha256_utf8_msg(&format!(
            "{}{}",
            event.content.key, self.state.json_start_content
        ));
        if self.state.commitment != commitment {
            Err(self.cancel(CancelCode::InvalidMessage))
        } else {
            let their_pubkey = mem::take(&mut event.content.key);
            self.inner
                .lock()
                .unwrap()
                .set_their_public_key(their_pubkey.clone())
                .expect("Can't set public key");
            Ok(SasState {
                inner: self.inner,
                ids: self.ids,
                verification_flow_id: self.verification_flow_id,
                creation_time: self.creation_time,
                last_event_time: self.last_event_time,
                state: Arc::new(KeyReceived {
                    their_pubkey,
                    we_started: true,
                    accepted_protocols: self.state.accepted_protocols.clone(),
                }),
            })
        }
    }
pub fn into_key_received ( self , event : & mut ToDeviceEvent < KeyEventContent > , ) -> Result < SasState < KeyReceived > , SasState < Canceled > > { self . check_event ( & event . sender , & event . content . transaction_id ) . map_err ( | c | self . clone ( ) . cancel ( c ) ) ? ; let utility = OlmUtility :: new ( ) ; let commitment = utility . sha256_utf8_msg ( & format ! ( " " event content key self state json_start_content ) ) ; if self . state . commitment != commitment { Err ( self . cancel ( CancelCode :: InvalidMessage ) ) } else { let their_pubkey = mem :: take ( & mut event . content . key ) ; self . inner . lock ( ) . unwrap ( ) . set_their_public_key ( their_pubkey . clone ( ) ) . expect ( " " ) ; Ok ( SasState { inner : self . inner , ids : self . ids , verification_flow_id : self . verification_flow_id , creation_time : self . creation_time , last_event_time : self . last_event_time , state : Arc :: new ( KeyReceived { their_pubkey , we_started : true , accepted_protocols : self . state . accepted_protocols . clone ( ) , } ) , } ) } }
Receive a m.key.verification.key event, changing the state into
a `KeyReceived` one
Receive a m . key . verification . key event changing the state into a ` KeyReceived ` one
self
event
&mut ToDeviceEvent<KeyEventContent>
self
event
&mut ToDeviceEvent<KeyEventContent>