Page MenuHomePhabricator

[services][identity] helper function to handle pake registration
AbandonedPublic

Authored by varun on May 26 2022, 12:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 12, 2:36 PM
Unknown Object (File)
Sat, May 4, 9:46 PM
Unknown Object (File)
Thu, May 2, 2:22 PM
Unknown Object (File)
Tue, Apr 30, 8:26 PM
Unknown Object (File)
Sun, Apr 28, 3:58 PM
Unknown Object (File)
Fri, Apr 26, 2:56 PM
Unknown Object (File)
Tue, Apr 23, 7:43 PM
Unknown Object (File)
Tue, Apr 23, 7:43 PM

Details

Summary

This helper function takes the PAKE registration bytes from the gRPC request and deserializes them. Then it generates a message to return to the client and sends the message to the bidi stream via the mpsc Sender.

I've also added an Error enum to this module. Thought it made sense to include both in a single diff for context.

Depends on D3962

Test Plan

confirmed that the Receiver of the mpsc channel received a RegistrationResponse

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

varun retitled this revision from [service][identity] helper function to handle pake registration to [services][identity] helper function to handle pake registration.May 27 2022, 10:42 AM

Make helper function a method

remove unnecessary import

karol added inline comments.
services/identity/src/config.rs
4

What is an exact reason for giving up on Default here?

services/identity/src/service.rs
70

Have you considered using Bytes? Maybe this crate also uses Vec<u8> so there's no difference? And if it does it differently, what are the pros and cons, and why do it manually? From Bytes docs:

It is intended for use primarily in networking code

71

What is this sorcery? Ok, this is a mutable reference to an object of a type that implements Rng and CryptoRng?

79

I don't get it. Why do we even care about Status (which is essentially an error, right?) if we use this function here to bump the error to the upper scope anyway? Is this Result<RegistrationResponse, Status> forced by some 3rd party lib or something?

86

So this function is just used to lift an error to the upper scope if something goes wrong, right?

This revision now requires changes to proceed.May 30 2022, 1:49 AM
This comment was removed by karol.
varun requested review of this revision.Jun 2 2022, 4:09 PM
varun added inline comments.
services/identity/src/config.rs
4

There is no implementation of the Default for Key. There was one for Option (None), which is why it worked before I removed the Option wrapper in the Config struct.

services/identity/src/service.rs
70

Since we're just serializing and deserializing this data, there's no advantage to using Bytes. If we were doing something more involved like slicing and dicing the bytes, I would probably use Bytes.

71

correct! traits make dependency injection pretty easy in rust

79

Is this Result<RegistrationResponse, Status> forced by some 3rd party lib or something?

This is correct. Tonic requires that the register_user method returns Result<Response<Self::RegisterUserStream>, Status>

86

correct

jim requested changes to this revision.Jun 3 2022, 8:23 AM
jim added inline comments.
services/identity/src/service.rs
70

@karol-bisztyga Is almost right, this should be a &[u8] byte slice, not a Vec. The hint is that deserialize takes a &[u8] and this param is passed straight in.

86

The map_err is not necessary since Error impls From<SendError<Result<...>>. Try with just the ?.

This revision now requires changes to proceed.Jun 3 2022, 8:23 AM