From 6111beded73b837d8b4f55949d4064e2a45a0819 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 17 May 2024 13:55:18 +0200 Subject: [PATCH] ffi: Expose ed25519/curve25519 keys in bindings (#3420) --- bindings/matrix-sdk-ffi/src/encryption.rs | 12 ++++++++++++ crates/matrix-sdk/src/encryption/mod.rs | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/encryption.rs b/bindings/matrix-sdk-ffi/src/encryption.rs index 4b321dabc..d7cb93ce1 100644 --- a/bindings/matrix-sdk-ffi/src/encryption.rs +++ b/bindings/matrix-sdk-ffi/src/encryption.rs @@ -213,6 +213,18 @@ impl From for VerificationState { #[uniffi::export(async_runtime = "tokio")] impl Encryption { + /// Get the public ed25519 key of our own device. This is usually what is + /// called the fingerprint of the device. + pub async fn ed25519_key(&self) -> Option { + self.inner.ed25519_key().await + } + + /// Get the public curve25519 key of our own device in base64. This is + /// usually what is called the identity key of the device. + pub async fn curve25519_key(&self) -> Option { + self.inner.curve25519_key().await + } + pub fn backup_state_listener(&self, listener: Box) -> Arc { let mut stream = self.inner.backups().state_stream(); diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index 0c7866fb0..2476c7a67 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -613,6 +613,12 @@ impl Encryption { self.client.olm_machine().await.as_ref().map(|o| o.identity_keys().ed25519.to_base64()) } + /// Get the public curve25519 key of our own device in base64. This is + /// usually what is called the identity key of the device. + pub async fn curve25519_key(&self) -> Option { + self.client.olm_machine().await.as_ref().map(|o| o.identity_keys().curve25519.to_base64()) + } + /// Get the status of the private cross signing keys. /// /// This can be used to check which private cross signing keys we have