diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -3,15 +3,17 @@ } use crate::client_service::client_proto::{ - DeleteUserRequest, DeviceKeysForUserRequest, DeviceKeysForUserResponse, - Empty, GenerateNonceResponse, KeyserverKeysRequest, KeyserverKeysResponse, - OpaqueLoginFinishRequest, OpaqueLoginFinishResponse, OpaqueLoginStartRequest, - OpaqueLoginStartResponse, RefreshUserPreKeysRequest, - RegistrationFinishRequest, RegistrationFinishResponse, - RegistrationStartRequest, RegistrationStartResponse, - UpdateUserPasswordFinishRequest, UpdateUserPasswordFinishResponse, - UpdateUserPasswordStartRequest, UpdateUserPasswordStartResponse, - UploadOneTimeKeysRequest, WalletLoginRequest, WalletLoginResponse, + DeleteUserRequest, Empty, GenerateNonceResponse, KeyserverKeysRequest, + KeyserverKeysResponse, OpaqueLoginFinishRequest, OpaqueLoginFinishResponse, + OpaqueLoginStartRequest, OpaqueLoginStartResponse, + ReceiverKeysForUserRequest, ReceiverKeysForUserResponse, + RefreshUserPreKeysRequest, RegistrationFinishRequest, + RegistrationFinishResponse, RegistrationStartRequest, + RegistrationStartResponse, SenderKeysForUserRequest, + SenderKeysForUserResponse, UpdateUserPasswordFinishRequest, + UpdateUserPasswordFinishResponse, UpdateUserPasswordStartRequest, + UpdateUserPasswordStartResponse, UploadOneTimeKeysRequest, + WalletLoginRequest, WalletLoginResponse, }; pub use client_proto::identity_client_service_server::{ IdentityClientService, IdentityClientServiceServer, @@ -87,10 +89,17 @@ unimplemented!(); } - async fn get_device_keys_for_user( + async fn get_receiver_keys_for_user( &self, - _request: tonic::Request, - ) -> Result, tonic::Status> { + _request: tonic::Request, + ) -> Result, tonic::Status> { + unimplemented!(); + } + + async fn get_sender_keys_for_user( + &self, + _request: tonic::Request, + ) -> Result, tonic::Status> { unimplemented!(); } diff --git a/shared/protos/identity_client.proto b/shared/protos/identity_client.proto --- a/shared/protos/identity_client.proto +++ b/shared/protos/identity_client.proto @@ -37,9 +37,17 @@ // X3DH actions // Called by clients to get all device keys associated with a user in order - // to open a new channel of communication on any of their devices - rpc GetDeviceKeysForUser(DeviceKeysForUserRequest) returns - (DeviceKeysForUserResponse) {} + // to open a new channel of communication on any of their devices. + // Specially, this will return the following per device: + // - Identity keys + // - PreKey (including preKey signature) + // - One-time PreKey + rpc GetReceiverKeysForUser(ReceiverKeysForUserRequest) returns + (ReceiverKeysForUserResponse) {} + // Called by receivers of a communication request. The reponse will only + // return identity and prekeys per device, but will not contain one-time keys. + rpc GetSenderKeysForUser(SenderKeysForUserRequest) returns + (SenderKeysForUserResponse) {} // Called by clients to get required keys for opening a connection // to a keyserver rpc GetKeyserverKeys(KeyserverKeysRequest) returns @@ -55,6 +63,11 @@ message Empty {} +message PreKey { + string preKey = 1; + string preKeySignature = 2; +} + // Key information needed for starting a X3DH session message IdentityKeyInfo { // JSON payload containing Olm Identity keys @@ -68,32 +81,6 @@ optional string socialProof = 3; } -// Ephemeral information provided to create initial message -// Prekeys are generally rotated periodically -// One-time Prekeys are "consumed" after first use -message PreKeyResponse { - // Rotating preKey, validated to be associatd with IdentityKeys - // through signature - string preKey = 4; - string preKeySignature = 5; - // One time key, removed from available list of one time keys after requested - // Client is also intended to remove OPKs after initial message - optional string onetimePrekey = 6; -} - -// Information needed when establishing communication to someone else's device -message RemoteDeviceInfo { - IdentityKeyInfo identityInfo = 1; - PreKeyResponse identityPrekeys = 2; - PreKeyResponse notifPrekeys = 3; -} - -// Information needed when establishing communication to a keyserver -message KeyserverSessionInfo { - IdentityKeyInfo identityInfo = 1; - PreKeyResponse identityPrekeys = 2; -} - // RegisterUser // Ephemeral information provided so others can create initial message @@ -102,21 +89,14 @@ // Prekeys are generally rotated periodically // One-time Prekeys are "consumed" after first use, so many need to // be provide to avoid exhausting them. -message PreKeyRegistrationUpload { - // Rotating preKey, validated to be associatd with IdentityKeys - // through signature - string preKey = 1; - string preKeySignature = 2; - // One time keys - // Removed from available list after requested by another client - repeated string onetimePrekeys = 3; -} // Bundle of information needed for creating an initial message using X3DH message DeviceKeyUpload { IdentityKeyInfo deviceKeyInfo = 1; - PreKeyRegistrationUpload identityUpload = 2; - PreKeyRegistrationUpload notifUpload = 3; + PreKey identityUpload = 2; + PreKey notifUpload = 3; + repeated string onetimeIdentityPrekeys = 4; + repeated string onetimeNotifPrekeys = 5; } // Request for registering a new user @@ -237,22 +217,61 @@ string nonce = 1; } -// GetDeviceKeysForUser +// GetReceiverKeysForUser + +// Information needed when establishing communication to someone else's device +message ReceiverKeyInfo { + IdentityKeyInfo identityInfo = 1; + PreKey identityPrekey = 2; + PreKey notifPrekey = 3; + optional string onetimeIdentityPrekey = 4; + optional string onetimeNotifPrekey = 5; +} -message DeviceKeysForUserRequest { +// Information needed by a device to establish communcation when responding +// to a request. +// The device receiving a request only needs the identity and prekeys. +message ReceiverKeysForUserRequest { oneof identifier { string username = 1; string walletAddress = 2; } } -message DeviceKeysForUserResponse { +message ReceiverKeysForUserResponse { // Map is keyed on devices' public ed25519 key used for signing - map devices = 1; + map devices = 1; +} + +// GetSenderKeysForUser + +message SenderKeyInfo { + IdentityKeyInfo identityInfo = 1; + PreKey identityPrekey = 2; + PreKey notifPrekey = 3; +} + +message SenderKeysForUserRequest { + oneof identifier { + string username = 1; + string walletAddress = 2; + } +} + +message SenderKeysForUserResponse { + // Map is keyed on devices' public ed25519 key used for signing + map devices = 1; } // GetKeyserverKeys +// Information needed when establishing communication to a keyserver +message KeyserverSessionInfo { + IdentityKeyInfo identityInfo = 1; + PreKey identityPrekeys = 2; + optional string onetimeIdentityPrekey = 5; +} + // All keyserver must be registered with an existing user. // Conversely, one or zero keyservers can registered to a user. message KeyserverKeysRequest { @@ -277,14 +296,7 @@ // RefreshUserPreKeys -message PreKeyUpload { - // Rotating preKey, validated to be associatd with IdentityKeys - // through signature - string preKey = 1; - string preKeySignature = 2; -} - message RefreshUserPreKeysRequest { string accessToken = 1; - PreKeyUpload newPreKeys = 2; + PreKey newPreKeys = 2; }