-
Notifications
You must be signed in to change notification settings - Fork 28
[native] implement CXX bindings to Vodozemac #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
2c625b5 to
d87e0e8
Compare
6018853 to
865c668
Compare
| } | ||
|
|
||
| // Vodozemac crypto functions | ||
| #[cfg(not(target_os = "ios"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's add a comment explaining that we're using an iOS check here instead of an Android check
- Let's update the spacing to match
native/vodozemac_bindings/src/lib.rs
| let olm_message: vodozemac::olm::OlmMessage = match message_type { | ||
| 0 => olm::PreKeyMessage::from_base64(encrypted_message.as_str()) | ||
| .map_err(|e| e.to_string())? | ||
| .into(), | ||
| 1 => olm::Message::from_base64(encrypted_message.as_str()) | ||
| .map_err(|e| e.to_string())? | ||
| .into(), | ||
| _ => return Err("wrong message type".to_string()), | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the TryFrom trait here
| ) -> Result<Box<VodozemacSession>, String> { | ||
| let key_bytes = session_key.as_bytes(); | ||
|
|
||
| //NOTE: vvodozemac works only with 32-byte keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: typo (two "v"s)
| return Err(base64_error.to_string()); | ||
| } | ||
| PickleError::Decryption(_) => { | ||
| println!("Decryption error, will try from_libolm_pickle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this log
| return Err(base64_error.to_string()); | ||
| } | ||
| PickleError::Decryption(_) => { | ||
| println!("Decryption error, will try from_libolm_pickle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this log
| pub struct VodozemacAccount(pub(crate) vodozemac::olm::Account); | ||
|
|
||
| impl From<Account> for VodozemacAccount { | ||
| fn from(account: Account) -> Self { | ||
| VodozemacAccount(account) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these below the InboundCreationResult stuff?
| .map_err(|e| e.to_string())?; | ||
| let signing_key = vodozemac::Ed25519PublicKey::from_base64(signing_key) | ||
| .map_err(|e| e.to_string())?; | ||
| let one_time_key = if one_time_key.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment explaining this here, and where we set it to an empty string on the C++ side?
865c668 to
de66670
Compare
| ) -> Result<Box<VodozemacSession>, String> { | ||
| let key_bytes = session_key.as_bytes(); | ||
|
|
||
| //NOTE: vodozemac works only with 32-byte keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: minor, no space before NOTE
Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Making vodozemac available on native. Branch needs to be updated after PRs are merged Test Plan: Tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15549
de66670 to
de276f7
Compare
* [lib][web][keyserver] replace Olm with Vodozemac's Olm Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). There is one thing with naming which is not obvious, this is using Olm name - Olm is still part of Vodozemac crate, so I think this is still correct, but I am okay with updating this too. I tried to make API as similar as it is possible, so there are files when changing import is everything we have to do. I redefined `EncryptResult` in `lib/`. Importing it from Olm was bad idea because it was used on native too, which causes Olm/Vodozemac wasm to be bundled into native, which worked with Olm but not with Vodozemac. Depends on D15547 Test Plan: Test encrypt/decrypt and creating session with Olm and Vodozemac. Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15548 * [native] implement CXX bindings to Vodozemac (#326) Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Making vodozemac available on native. Branch needs to be updated after PRs are merged Test Plan: Tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15549
…#324) * [lib][web][keyserver] add Vodozemac library and `.wasm` file handling Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Using the same pattern as have for existing `.wasm` files (Olm, SQLite and Backup Client). Currently linking my local library, so CI will fail. This should be updated to NPM package after CommE2E/vodozemac#3 is merged and published. This diff shouldn't be landed without following one with API migration, because it replaces initializing Olm with Vodozemac, so Olm is not working anymore. Depends on D15546 Test Plan: Run web and keyserver, vodozemac should be available, usage tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15547 * [lib][web][keyserver] replace Olm with Vodozemac's Olm (#325) * [lib][web][keyserver] replace Olm with Vodozemac's Olm Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). There is one thing with naming which is not obvious, this is using Olm name - Olm is still part of Vodozemac crate, so I think this is still correct, but I am okay with updating this too. I tried to make API as similar as it is possible, so there are files when changing import is everything we have to do. I redefined `EncryptResult` in `lib/`. Importing it from Olm was bad idea because it was used on native too, which causes Olm/Vodozemac wasm to be bundled into native, which worked with Olm but not with Vodozemac. Depends on D15547 Test Plan: Test encrypt/decrypt and creating session with Olm and Vodozemac. Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15548 * [native] implement CXX bindings to Vodozemac (#326) Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Making vodozemac available on native. Branch needs to be updated after PRs are merged Test Plan: Tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15549
…#324) * [lib][web][keyserver] add Vodozemac library and `.wasm` file handling Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Using the same pattern as have for existing `.wasm` files (Olm, SQLite and Backup Client). Currently linking my local library, so CI will fail. This should be updated to NPM package after CommE2E/vodozemac#3 is merged and published. This diff shouldn't be landed without following one with API migration, because it replaces initializing Olm with Vodozemac, so Olm is not working anymore. Depends on D15546 Test Plan: Run web and keyserver, vodozemac should be available, usage tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15547 * [lib][web][keyserver] replace Olm with Vodozemac's Olm (#325) * [lib][web][keyserver] replace Olm with Vodozemac's Olm Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). There is one thing with naming which is not obvious, this is using Olm name - Olm is still part of Vodozemac crate, so I think this is still correct, but I am okay with updating this too. I tried to make API as similar as it is possible, so there are files when changing import is everything we have to do. I redefined `EncryptResult` in `lib/`. Importing it from Olm was bad idea because it was used on native too, which causes Olm/Vodozemac wasm to be bundled into native, which worked with Olm but not with Vodozemac. Depends on D15547 Test Plan: Test encrypt/decrypt and creating session with Olm and Vodozemac. Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15548 * [native] implement CXX bindings to Vodozemac (#326) Summary: [ENG-11531](https://linear.app/comm/issue/ENG-11531/migrate-the-full-crypto-api-to-vodozemac). Making vodozemac available on native. Branch needs to be updated after PRs are merged Test Plan: Tested in next diff Reviewers: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D15549
Summary:
ENG-11531.
Making Vodozemac available on native.
Test Plan: Tested in the next diff
Reviewers: ashoat
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D15549