diff --git a/rust/bridge/shared/src/ffi/storage.rs b/rust/bridge/shared/src/ffi/storage.rs index a9ba4894a0..9adacbe1d2 100644 --- a/rust/bridge/shared/src/ffi/storage.rs +++ b/rust/bridge/shared/src/ffi/storage.rs @@ -194,12 +194,12 @@ pub struct FfiPreKeyStoreStruct { impl PreKeyStore for &FfiPreKeyStoreStruct { async fn get_pre_key( &self, - prekey_id: u32, + prekey_id: PreKeyId, ctx: Context, ) -> Result { let ctx = ctx.unwrap_or(std::ptr::null_mut()); let mut record = std::ptr::null_mut(); - let result = (self.load_pre_key)(self.ctx, &mut record, prekey_id, ctx); + let result = (self.load_pre_key)(self.ctx, &mut record, prekey_id.into(), ctx); if let Some(error) = CallbackError::check(result) { return Err(SignalProtocolError::ApplicationCallbackError( @@ -218,12 +218,12 @@ impl PreKeyStore for &FfiPreKeyStoreStruct { async fn save_pre_key( &mut self, - prekey_id: u32, + prekey_id: PreKeyId, record: &PreKeyRecord, ctx: Context, ) -> Result<(), SignalProtocolError> { let ctx = ctx.unwrap_or(std::ptr::null_mut()); - let result = (self.store_pre_key)(self.ctx, prekey_id, &*record, ctx); + let result = (self.store_pre_key)(self.ctx, prekey_id.into(), &*record, ctx); if let Some(error) = CallbackError::check(result) { return Err(SignalProtocolError::ApplicationCallbackError( @@ -237,11 +237,11 @@ impl PreKeyStore for &FfiPreKeyStoreStruct { async fn remove_pre_key( &mut self, - prekey_id: u32, + prekey_id: PreKeyId, ctx: Context, ) -> Result<(), SignalProtocolError> { let ctx = ctx.unwrap_or(std::ptr::null_mut()); - let result = (self.remove_pre_key)(self.ctx, prekey_id, ctx); + let result = (self.remove_pre_key)(self.ctx, prekey_id.into(), ctx); if let Some(error) = CallbackError::check(result) { return Err(SignalProtocolError::ApplicationCallbackError( diff --git a/rust/bridge/shared/src/jni/storage.rs b/rust/bridge/shared/src/jni/storage.rs index 88280fc7ec..8c5f94042e 100644 --- a/rust/bridge/shared/src/jni/storage.rs +++ b/rust/bridge/shared/src/jni/storage.rs @@ -277,27 +277,27 @@ impl<'a> JniPreKeyStore<'a> { impl<'a> PreKeyStore for JniPreKeyStore<'a> { async fn get_pre_key( &self, - prekey_id: u32, + prekey_id: PreKeyId, _ctx: Context, ) -> Result { - Ok(self.do_get_pre_key(prekey_id)?) + Ok(self.do_get_pre_key(prekey_id.into())?) } async fn save_pre_key( &mut self, - prekey_id: u32, + prekey_id: PreKeyId, record: &PreKeyRecord, _ctx: Context, ) -> Result<(), SignalProtocolError> { - Ok(self.do_save_pre_key(prekey_id, record)?) + Ok(self.do_save_pre_key(prekey_id.into(), record)?) } async fn remove_pre_key( &mut self, - prekey_id: u32, + prekey_id: PreKeyId, _ctx: Context, ) -> Result<(), SignalProtocolError> { - Ok(self.do_remove_pre_key(prekey_id)?) + Ok(self.do_remove_pre_key(prekey_id.into())?) } } diff --git a/rust/bridge/shared/src/node/storage.rs b/rust/bridge/shared/src/node/storage.rs index dc33f75c1e..d472b98ffd 100644 --- a/rust/bridge/shared/src/node/storage.rs +++ b/rust/bridge/shared/src/node/storage.rs @@ -105,31 +105,31 @@ impl Finalize for NodePreKeyStore { impl PreKeyStore for NodePreKeyStore { async fn get_pre_key( &self, - pre_key_id: u32, + pre_key_id: PreKeyId, _ctx: libsignal_protocol::Context, ) -> Result { - self.do_get_pre_key(pre_key_id) + self.do_get_pre_key(pre_key_id.into()) .await .map_err(|s| js_error_to_rust("getPreKey", s)) } async fn save_pre_key( &mut self, - pre_key_id: u32, + pre_key_id: PreKeyId, record: &PreKeyRecord, _ctx: libsignal_protocol::Context, ) -> Result<(), SignalProtocolError> { - self.do_save_pre_key(pre_key_id, record.clone()) + self.do_save_pre_key(pre_key_id.into(), record.clone()) .await .map_err(|s| js_error_to_rust("savePreKey", s)) } async fn remove_pre_key( &mut self, - pre_key_id: u32, + pre_key_id: PreKeyId, _ctx: libsignal_protocol::Context, ) -> Result<(), SignalProtocolError> { - self.do_remove_pre_key(pre_key_id) + self.do_remove_pre_key(pre_key_id.into()) .await .map_err(|s| js_error_to_rust("removePreKey", s)) } diff --git a/rust/bridge/shared/src/protocol.rs b/rust/bridge/shared/src/protocol.rs index 161072aeb5..0a2f453db1 100644 --- a/rust/bridge/shared/src/protocol.rs +++ b/rust/bridge/shared/src/protocol.rs @@ -286,7 +286,7 @@ fn PreKeySignalMessage_New( PreKeySignalMessage::new( message_version, registration_id, - pre_key_id, + pre_key_id.map(|id| id.into()), signed_pre_key_id.into(), *base_key, IdentityKey::new(*identity_key), @@ -520,9 +520,9 @@ fn PreKeyBundle_New( ) -> Result { let identity_key = IdentityKey::new(*identity_key); - let prekey = match (prekey, prekey_id) { + let prekey: Option<(PreKeyId, PublicKey)> = match (prekey, prekey_id) { (None, None) => None, - (Some(k), Some(id)) => Some((id, *k)), + (Some(k), Some(id)) => Some((id.into(), *k)), _ => { return Err(SignalProtocolError::InvalidArgument( "Must supply both or neither of prekey and prekey_id".to_owned(), @@ -589,7 +589,7 @@ bridge_get!(PreKeyRecord::private_key -> PrivateKey); #[bridge_fn] fn PreKeyRecord_New(id: u32, pub_key: &PublicKey, priv_key: &PrivateKey) -> PreKeyRecord { let keypair = KeyPair::new(*pub_key, *priv_key); - PreKeyRecord::new(id, &keypair) + PreKeyRecord::new(id.into(), &keypair) } bridge_deserialize!(SenderKeyRecord::deserialize); diff --git a/rust/protocol/src/lib.rs b/rust/protocol/src/lib.rs index 087ea4eb26..9480829fc5 100644 --- a/rust/protocol/src/lib.rs +++ b/rust/protocol/src/lib.rs @@ -75,7 +75,9 @@ pub use { session_cipher::{ message_decrypt, message_decrypt_prekey, message_decrypt_signal, message_encrypt, }, - state::{PreKeyBundle, PreKeyRecord, SessionRecord, SignedPreKeyId, SignedPreKeyRecord}, + state::{ + PreKeyBundle, PreKeyId, PreKeyRecord, SessionRecord, SignedPreKeyId, SignedPreKeyRecord, + }, storage::{ Context, Direction, IdentityKeyStore, InMemIdentityKeyStore, InMemPreKeyStore, InMemSenderKeyStore, InMemSessionStore, InMemSignalProtocolStore, InMemSignedPreKeyStore, diff --git a/rust/protocol/src/protocol.rs b/rust/protocol/src/protocol.rs index 4c8e150c78..26ebc30797 100644 --- a/rust/protocol/src/protocol.rs +++ b/rust/protocol/src/protocol.rs @@ -4,7 +4,7 @@ // use crate::proto; -use crate::state::SignedPreKeyId; +use crate::state::{PreKeyId, SignedPreKeyId}; use crate::{IdentityKey, PrivateKey, PublicKey, Result, SignalProtocolError}; use std::convert::TryFrom; @@ -238,7 +238,7 @@ impl TryFrom<&[u8]> for SignalMessage { pub struct PreKeySignalMessage { message_version: u8, registration_id: u32, - pre_key_id: Option, + pre_key_id: Option, signed_pre_key_id: SignedPreKeyId, base_key: PublicKey, identity_key: IdentityKey, @@ -250,7 +250,7 @@ impl PreKeySignalMessage { pub fn new( message_version: u8, registration_id: u32, - pre_key_id: Option, + pre_key_id: Option, signed_pre_key_id: SignedPreKeyId, base_key: PublicKey, identity_key: IdentityKey, @@ -258,7 +258,7 @@ impl PreKeySignalMessage { ) -> Result { let proto_message = proto::wire::PreKeySignalMessage { registration_id: Some(registration_id), - pre_key_id, + pre_key_id: pre_key_id.map(|id| id.into()), signed_pre_key_id: Some(signed_pre_key_id.into()), base_key: Some(base_key.serialize().into_vec()), identity_key: Some(identity_key.serialize().into_vec()), @@ -290,7 +290,7 @@ impl PreKeySignalMessage { } #[inline] - pub fn pre_key_id(&self) -> Option { + pub fn pre_key_id(&self) -> Option { self.pre_key_id } @@ -366,7 +366,7 @@ impl TryFrom<&[u8]> for PreKeySignalMessage { Ok(PreKeySignalMessage { message_version, registration_id: proto_structure.registration_id.unwrap_or(0), - pre_key_id: proto_structure.pre_key_id, + pre_key_id: proto_structure.pre_key_id.map(|id| id.into()), signed_pre_key_id: signed_pre_key_id.into(), base_key, identity_key: IdentityKey::try_from(identity_key.as_ref())?, diff --git a/rust/protocol/src/session.rs b/rust/protocol/src/session.rs index a2e9b30201..8658629013 100644 --- a/rust/protocol/src/session.rs +++ b/rust/protocol/src/session.rs @@ -4,13 +4,13 @@ // use crate::{ - Context, Direction, IdentityKeyStore, KeyPair, PreKeyBundle, PreKeySignalMessage, PreKeyStore, - ProtocolAddress, Result, SessionRecord, SessionStore, SignalProtocolError, SignedPreKeyStore, + Context, Direction, IdentityKeyStore, KeyPair, PreKeyBundle, PreKeyId, PreKeySignalMessage, + PreKeyStore, ProtocolAddress, Result, SessionRecord, SessionStore, SignalProtocolError, + SignedPreKeyStore, }; use crate::ratchet; use crate::ratchet::{AliceSignalProtocolParameters, BobSignalProtocolParameters}; -use crate::state::PreKeyId; use rand::{CryptoRng, Rng}; /* @@ -178,7 +178,7 @@ pub async fn process_prekey_bundle( log::info!( "set_unacknowledged_pre_key_message for: {} with preKeyId: {}", remote_address, - their_one_time_prekey_id.map_or_else(|| "".to_string(), |id| id.to_string()) + their_one_time_prekey_id.map_or_else(|| "".to_string(), |id| format!("{:?}", id)) ); session.set_unacknowledged_pre_key_message( diff --git a/rust/protocol/src/session_cipher.rs b/rust/protocol/src/session_cipher.rs index 0625a0aa74..58775c785f 100644 --- a/rust/protocol/src/session_cipher.rs +++ b/rust/protocol/src/session_cipher.rs @@ -53,7 +53,7 @@ pub async fn message_encrypt( remote_address, items .pre_key_id()? - .map_or_else(|| "".to_string(), |id| id.to_string()) + .map_or_else(|| "".to_string(), |id| format!("{:?}", id)) ); let message = SignalMessage::new( diff --git a/rust/protocol/src/state/prekey.rs b/rust/protocol/src/state/prekey.rs index 5927a7987c..ac0c2cce96 100644 --- a/rust/protocol/src/state/prekey.rs +++ b/rust/protocol/src/state/prekey.rs @@ -7,7 +7,21 @@ use crate::proto::storage::PreKeyRecordStructure; use crate::{KeyPair, PrivateKey, PublicKey, Result}; use prost::Message; -pub type PreKeyId = u32; +/// A unique identifier selecting among this client's known pre-keys. +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +pub struct PreKeyId(pub u32); + +impl From for PreKeyId { + fn from(value: u32) -> Self { + Self(value) + } +} + +impl From for u32 { + fn from(value: PreKeyId) -> Self { + value.0 + } +} #[derive(Debug, Clone)] pub struct PreKeyRecord { @@ -20,7 +34,7 @@ impl PreKeyRecord { let private_key = key.private_key.serialize().to_vec(); Self { pre_key: PreKeyRecordStructure { - id, + id: id.into(), public_key, private_key, }, @@ -34,7 +48,7 @@ impl PreKeyRecord { } pub fn id(&self) -> Result { - Ok(self.pre_key.id) + Ok(self.pre_key.id.into()) } pub fn key_pair(&self) -> Result { diff --git a/rust/protocol/src/state/session.rs b/rust/protocol/src/state/session.rs index 9844deb57a..73ee5116ff 100644 --- a/rust/protocol/src/state/session.rs +++ b/rust/protocol/src/state/session.rs @@ -388,7 +388,7 @@ impl SessionState { ) -> Result<()> { let signed_pre_key_id: u32 = signed_pre_key_id.into(); let pending = session_structure::PendingPreKey { - pre_key_id: pre_key_id.unwrap_or(0), + pre_key_id: pre_key_id.unwrap_or(0.into()).into(), signed_pre_key_id: signed_pre_key_id as i32, base_key: base_key.serialize().to_vec(), }; @@ -403,7 +403,7 @@ impl SessionState { Ok(Some(UnacknowledgedPreKeyMessageItems::new( match pending_pre_key.pre_key_id { 0 => None, - v => Some(v), + v => Some(v.into()), }, (pending_pre_key.signed_pre_key_id as u32).into(), PublicKey::deserialize(&pending_pre_key.base_key)?, diff --git a/rust/protocol/src/storage/inmem.rs b/rust/protocol/src/storage/inmem.rs index 3567ac0597..1970ba430b 100644 --- a/rust/protocol/src/storage/inmem.rs +++ b/rust/protocol/src/storage/inmem.rs @@ -4,11 +4,10 @@ // use crate::{ - IdentityKey, IdentityKeyPair, PreKeyRecord, ProtocolAddress, Result, SenderKeyRecord, - SessionRecord, SignalProtocolError, SignedPreKeyRecord, + IdentityKey, IdentityKeyPair, PreKeyId, PreKeyRecord, ProtocolAddress, Result, SenderKeyRecord, + SessionRecord, SignalProtocolError, SignedPreKeyId, SignedPreKeyRecord, }; -use crate::state::{PreKeyId, SignedPreKeyId}; use crate::storage::traits; use crate::storage::Context; diff --git a/rust/protocol/tests/session.rs b/rust/protocol/tests/session.rs index 15421333dc..a2c7767ef3 100644 --- a/rust/protocol/tests/session.rs +++ b/rust/protocol/tests/session.rs @@ -38,9 +38,9 @@ fn test_basic_prekey_v3() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id, bob_pre_key_pair.public_key)), // pre key - signed_pre_key_id.into(), // signed pre key id + DeviceId(1), // device id + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), // pre key + signed_pre_key_id.into(), // signed pre key id bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), *bob_store.get_identity_key_pair(None).await?.identity_key(), @@ -84,8 +84,8 @@ fn test_basic_prekey_v3() -> Result<(), SignalProtocolError> { bob_store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &bob_pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &bob_pre_key_pair), None, ) .await?; @@ -158,8 +158,8 @@ fn test_basic_prekey_v3() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id + 1, bob_pre_key_pair.public_key)), // pre key, + DeviceId(1), // device id + Some(((pre_key_id + 1).into(), bob_pre_key_pair.public_key)), // pre key, (signed_pre_key_id + 1).into(), bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), @@ -168,8 +168,8 @@ fn test_basic_prekey_v3() -> Result<(), SignalProtocolError> { bob_store .save_pre_key( - pre_key_id + 1, - &PreKeyRecord::new(pre_key_id + 1, &bob_pre_key_pair), + (pre_key_id + 1).into(), + &PreKeyRecord::new((pre_key_id + 1).into(), &bob_pre_key_pair), None, ) .await?; @@ -227,8 +227,8 @@ fn test_basic_prekey_v3() -> Result<(), SignalProtocolError> { // Sign pre-key with wrong key: let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id, bob_pre_key_pair.public_key)), // pre key + DeviceId(1), // device id + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), // pre key signed_pre_key_id.into(), bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), @@ -283,9 +283,9 @@ fn chain_jump_over_limit() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id, bob_pre_key_pair.public_key)), // pre key - signed_pre_key_id.into(), // signed pre key id + DeviceId(1), // device id + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), // pre key + signed_pre_key_id.into(), // signed pre key id bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), *bob_store.get_identity_key_pair(None).await?.identity_key(), @@ -303,8 +303,8 @@ fn chain_jump_over_limit() -> Result<(), SignalProtocolError> { bob_store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &bob_pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &bob_pre_key_pair), None, ) .await?; @@ -374,9 +374,9 @@ fn chain_jump_over_limit_with_self() -> Result<(), SignalProtocolError> { let a2_pre_key_bundle = PreKeyBundle::new( a2_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id, a2_pre_key_pair.public_key)), // pre key - signed_pre_key_id.into(), // signed pre key id + DeviceId(1), // device id + Some((pre_key_id.into(), a2_pre_key_pair.public_key)), // pre key + signed_pre_key_id.into(), // signed pre key id a2_signed_pre_key_pair.public_key, a2_signed_pre_key_signature.to_vec(), *a2_store.get_identity_key_pair(None).await?.identity_key(), @@ -394,8 +394,8 @@ fn chain_jump_over_limit_with_self() -> Result<(), SignalProtocolError> { a2_store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &a2_pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &a2_pre_key_pair), None, ) .await?; @@ -475,7 +475,7 @@ fn test_bad_signed_pre_key_signature() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, DeviceId(1), - Some((pre_key_id, bob_pre_key_pair.public_key)), + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), signed_pre_key_id.into(), bob_signed_pre_key_pair.public_key, bad_signature, @@ -499,7 +499,7 @@ fn test_bad_signed_pre_key_signature() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, DeviceId(1), - Some((pre_key_id, bob_pre_key_pair.public_key)), + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), signed_pre_key_id.into(), bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature, @@ -550,9 +550,9 @@ fn repeat_bundle_message_v3() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, - DeviceId(1), // device id - Some((pre_key_id, bob_pre_key_pair.public_key)), // pre key - signed_pre_key_id.into(), // signed pre key id + DeviceId(1), // device id + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), // pre key + signed_pre_key_id.into(), // signed pre key id bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), *bob_store.get_identity_key_pair(None).await?.identity_key(), @@ -601,8 +601,8 @@ fn repeat_bundle_message_v3() -> Result<(), SignalProtocolError> { bob_store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &bob_pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &bob_pre_key_pair), None, ) .await?; @@ -686,7 +686,7 @@ fn bad_message_bundle() -> Result<(), SignalProtocolError> { let bob_pre_key_bundle = PreKeyBundle::new( bob_store.get_local_registration_id(None).await?, DeviceId(1), // device id - Some((pre_key_id, bob_pre_key_pair.public_key)), + Some((pre_key_id.into(), bob_pre_key_pair.public_key)), signed_pre_key_id.into(), // signed pre key id bob_signed_pre_key_pair.public_key, bob_signed_pre_key_signature.to_vec(), @@ -705,8 +705,8 @@ fn bad_message_bundle() -> Result<(), SignalProtocolError> { bob_store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &bob_pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &bob_pre_key_pair), None, ) .await?; @@ -738,7 +738,7 @@ fn bad_message_bundle() -> Result<(), SignalProtocolError> { let original_message = "L'homme est condamné à être libre"; - assert!(bob_store.get_pre_key(pre_key_id, None).await.is_ok()); + assert!(bob_store.get_pre_key(pre_key_id.into(), None).await.is_ok()); let outgoing_message = encrypt(&mut alice_store, &bob_address, original_message).await?; assert_eq!( @@ -758,7 +758,7 @@ fn bad_message_bundle() -> Result<(), SignalProtocolError> { assert!(decrypt(&mut bob_store, &alice_address, &incoming_message) .await .is_err()); - assert!(bob_store.get_pre_key(pre_key_id, None).await.is_ok()); + assert!(bob_store.get_pre_key(pre_key_id.into(), None).await.is_ok()); let incoming_message = CiphertextMessage::PreKeySignalMessage( PreKeySignalMessage::try_from(outgoing_message.as_slice())?, @@ -771,7 +771,10 @@ fn bad_message_bundle() -> Result<(), SignalProtocolError> { original_message ); assert!(matches!( - bob_store.get_pre_key(pre_key_id, None).await.unwrap_err(), + bob_store + .get_pre_key(pre_key_id.into(), None) + .await + .unwrap_err(), SignalProtocolError::InvalidPreKeyId )); diff --git a/rust/protocol/tests/support/mod.rs b/rust/protocol/tests/support/mod.rs index 877b1cccfb..01d9d51336 100644 --- a/rust/protocol/tests/support/mod.rs +++ b/rust/protocol/tests/support/mod.rs @@ -72,7 +72,7 @@ pub async fn create_pre_key_bundle( let pre_key_bundle = PreKeyBundle::new( store.get_local_registration_id(None).await?, device_id.into(), - Some((pre_key_id, pre_key_pair.public_key)), + Some((pre_key_id.into(), pre_key_pair.public_key)), signed_pre_key_id.into(), signed_pre_key_pair.public_key, signed_pre_key_signature.to_vec(), @@ -81,8 +81,8 @@ pub async fn create_pre_key_bundle( store .save_pre_key( - pre_key_id, - &PreKeyRecord::new(pre_key_id, &pre_key_pair), + pre_key_id.into(), + &PreKeyRecord::new(pre_key_id.into(), &pre_key_pair), None, ) .await?;