Conversation
| pub fn new_responder(seed_key: SecretKey, dh_self: InstallationKeyPair) -> Self { | ||
| Self { | ||
| // TODO: Danger - Fix double-ratchets types to Accept SecretKey | ||
| dr_state: RatchetState::init_receiver(seed_key.as_bytes().to_owned(), dh_self), | ||
| } | ||
| } |
There was a problem hiding this comment.
double-ratchets requires a InstallationKey struct to be passed in.
As InstallationKey is just a thin wrapper around StaticKey @kaichaosun would you be ok if I refactored double-ratchets to use a common keyType as the rest of the cryptography? It would be a StructWrapper around StaticKey which would have the effect:
- Keys can be passed without extra copies for clearer memory hygiene.
- Remove DR direct dependence on x25519 in our entire codebase.
- Avoid Needless copies
We can add an AbstractType or Trait Generics if we really want it to be completely independent in the future.
| let header = Header { | ||
| dh_pub, | ||
| msg_num: dr_header.msg_num, | ||
| prev_chain_len: dr_header.prev_chain_len, | ||
| }; |
There was a problem hiding this comment.
Orphan rule is making handling these DR types kind of annoying. I'll look at using Newtype and implementing the conversions there
| pub fn new_responder(seed_key: SecretKey, dh_self: InstallationKeyPair) -> Self { | ||
| Self { | ||
| // TODO: Danger - Fix double-ratchets types to Accept SecretKey | ||
| dr_state: RatchetState::init_receiver(seed_key.as_bytes().to_owned(), dh_self), |
There was a problem hiding this comment.
Feel free to make roles name consistent in different crates.
| } | ||
|
|
||
| fn encrypt(&mut self, frame: PrivateV1Frame) -> EncryptedPayload { | ||
| let encoded_bytes = frame.encode_to_vec(); |
There was a problem hiding this comment.
I think the name can be shorter like to_bytes or something similar
There was a problem hiding this comment.
what do you mean @kaichaosun ? I don't follow.
There was a problem hiding this comment.
It just looks so strange to use encode_to_vec other than something like to_bytes, since it comes from generated code, seems we can do nothing about it.
|
I wanted to wait for #37 to land, before integrating this. However to keep things simple I'll push this through and then comeback to it. |
This PR incorporates the double ratchet into the PrivateV1 by initializing sessions and wiring up Encrypt and Decrypt.