Skip to content

Commit

Permalink
respond to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed May 13, 2021
1 parent f856d2c commit 44184fd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rust/bridge/shared/src/ffi/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl IdentityKeyStore for &FfiIdentityKeyStoreStruct {
async fn get_local_registration_id(
&self,
ctx: Context,
) -> Result<SessionSeed, SignalProtocolError> {
) -> Result<RegistrationId, SignalProtocolError> {
let ctx = ctx.unwrap_or(std::ptr::null_mut());
let mut id = 0;
let result = (self.get_local_registration_id)(self.ctx, &mut id, ctx);
Expand Down
2 changes: 1 addition & 1 deletion rust/bridge/shared/src/jni/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'a> IdentityKeyStore for JniIdentityKeyStore<'a> {
async fn get_local_registration_id(
&self,
_ctx: Context,
) -> Result<SessionSeed, SignalProtocolError> {
) -> Result<RegistrationId, SignalProtocolError> {
Ok(self.do_get_local_registration_id()?.into())
}

Expand Down
2 changes: 1 addition & 1 deletion rust/bridge/shared/src/node/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ impl IdentityKeyStore for NodeIdentityKeyStore {
async fn get_local_registration_id(
&self,
_ctx: libsignal_protocol::Context,
) -> Result<SessionSeed, SignalProtocolError> {
) -> Result<RegistrationId, SignalProtocolError> {
Ok(self
.do_get_local_registration_id()
.await
Expand Down
2 changes: 1 addition & 1 deletion rust/protocol/src/group_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub async fn process_sender_key_distribution_message(
.unwrap_or_else(SenderKeyRecord::new_empty);

sender_key_record.add_sender_key_state(
skdm.message_version(),
skdm.message_version().into(),
skdm.chain_id()?,
skdm.iteration()?,
skdm.chain_key()?,
Expand Down
2 changes: 1 addition & 1 deletion rust/protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ pub use {
storage::{
Context, Direction, IdentityKeyStore, InMemIdentityKeyStore, InMemPreKeyStore,
InMemSenderKeyStore, InMemSessionStore, InMemSignalProtocolStore, InMemSignedPreKeyStore,
PreKeyStore, ProtocolStore, SenderKeyStore, SessionSeed, SessionStore, SignedPreKeyStore,
PreKeyStore, ProtocolStore, SenderKeyStore, RegistrationId, SessionStore, SignedPreKeyStore,
},
};
2 changes: 1 addition & 1 deletion rust/protocol/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ pub use {
},
traits::{
Context, Direction, IdentityKeyStore, PreKeyStore, ProtocolStore, SenderKeyStore,
SessionSeed, SessionStore, SignedPreKeyStore,
RegistrationId, SessionStore, SignedPreKeyStore,
},
};
12 changes: 6 additions & 6 deletions rust/protocol/src/storage/inmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use crate::{
IdentityKey, IdentityKeyPair, PreKeyId, PreKeyRecord, ProtocolAddress, Result, SenderKeyRecord,
SessionRecord, SessionSeed, SignalProtocolError, SignedPreKeyId, SignedPreKeyRecord,
SessionRecord, RegistrationId, SignalProtocolError, SignedPreKeyId, SignedPreKeyRecord,
};

use crate::storage::traits;
Expand All @@ -19,12 +19,12 @@ use uuid::Uuid;
#[derive(Clone)]
pub struct InMemIdentityKeyStore {
key_pair: IdentityKeyPair,
id: SessionSeed,
id: RegistrationId,
known_keys: HashMap<ProtocolAddress, IdentityKey>,
}

impl InMemIdentityKeyStore {
pub fn new(key_pair: IdentityKeyPair, id: SessionSeed) -> Self {
pub fn new(key_pair: IdentityKeyPair, id: RegistrationId) -> Self {
Self {
key_pair,
id,
Expand All @@ -39,7 +39,7 @@ impl traits::IdentityKeyStore for InMemIdentityKeyStore {
Ok(self.key_pair)
}

async fn get_local_registration_id(&self, _ctx: Context) -> Result<SessionSeed> {
async fn get_local_registration_id(&self, _ctx: Context) -> Result<RegistrationId> {
Ok(self.id)
}

Expand Down Expand Up @@ -286,7 +286,7 @@ pub struct InMemSignalProtocolStore {
}

impl InMemSignalProtocolStore {
pub fn new(key_pair: IdentityKeyPair, registration_id: SessionSeed) -> Result<Self> {
pub fn new(key_pair: IdentityKeyPair, registration_id: RegistrationId) -> Result<Self> {
Ok(Self {
session_store: InMemSessionStore::new(),
pre_key_store: InMemPreKeyStore::new(),
Expand All @@ -303,7 +303,7 @@ impl traits::IdentityKeyStore for InMemSignalProtocolStore {
self.identity_store.get_identity_key_pair(ctx).await
}

async fn get_local_registration_id(&self, ctx: Context) -> Result<SessionSeed> {
async fn get_local_registration_id(&self, ctx: Context) -> Result<RegistrationId> {
self.identity_store.get_local_registration_id(ctx).await
}

Expand Down
10 changes: 5 additions & 5 deletions rust/protocol/src/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ pub enum Direction {

/// A locally-generated random number used to construct the initial value of a message chain.
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
pub struct SessionSeed(u32);
pub struct RegistrationId(u32);

impl From<u32> for SessionSeed {
impl From<u32> for RegistrationId {
fn from(value: u32) -> Self {
Self(value)
}
}

impl From<SessionSeed> for u32 {
fn from(value: SessionSeed) -> Self {
impl From<RegistrationId> for u32 {
fn from(value: RegistrationId) -> Self {
value.0
}
}
Expand All @@ -40,7 +40,7 @@ impl From<SessionSeed> for u32 {
pub trait IdentityKeyStore {
async fn get_identity_key_pair(&self, ctx: Context) -> Result<IdentityKeyPair>;

async fn get_local_registration_id(&self, ctx: Context) -> Result<SessionSeed>;
async fn get_local_registration_id(&self, ctx: Context) -> Result<RegistrationId>;

async fn save_identity(
&mut self,
Expand Down

0 comments on commit 44184fd

Please sign in to comment.