diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index 8d846cc3..42ecde31 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -205,10 +205,7 @@ impl OlmMachine { continue; }; - let one_time_key = if let Some(k) = key_map.get(&AlgorithmAndDeviceId( - KeyAlgorithm::SignedCurve25519, - device_id.to_owned(), - )) { + let one_time_key = if let Some(k) = key_map.values().nth(0) { match k { OneTimeKey::SignedKey(k) => k, OneTimeKey::Key(_) => { @@ -268,7 +265,7 @@ impl OlmMachine { .account .lock() .await - .create_outbound_session(&one_time_key.key, curve_key) + .create_outbound_session(curve_key, &one_time_key) { Ok(s) => s, Err(e) => { diff --git a/src/crypto/olm.rs b/src/crypto/olm.rs index 1165b899..7302c339 100644 --- a/src/crypto/olm.rs +++ b/src/crypto/olm.rs @@ -21,6 +21,8 @@ use olm_rs::inbound_group_session::OlmInboundGroupSession; use olm_rs::session::{OlmMessage, OlmSession, PreKeyMessage}; use olm_rs::PicklingMode; +use ruma_client_api::r0::keys::SignedKey; + pub struct Account { inner: OlmAccount, pub(crate) shared: bool, @@ -106,11 +108,11 @@ impl Account { pub fn create_outbound_session( &self, their_identity_key: &str, - their_one_time_key: &str, + their_one_time_key: &SignedKey, ) -> Result { let session = self .inner - .create_outbound_session(their_identity_key, their_one_time_key)?; + .create_outbound_session(their_identity_key, &their_one_time_key.key)?; let now = Instant::now();