Skip to content

Conversation

@xsanm
Copy link
Collaborator

@xsanm xsanm commented Dec 2, 2025

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

@xsanm xsanm requested a review from Ashoat December 2, 2025 16:02
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@xsanm xsanm force-pushed the vodozemac-work-part-3 branch 3 times, most recently from 2c625b5 to d87e0e8 Compare December 3, 2025 16:11
@xsanm xsanm force-pushed the vodozemac-work-part-4 branch 2 times, most recently from 6018853 to 865c668 Compare December 3, 2025 16:15
}

// Vodozemac crypto functions
#[cfg(not(target_os = "ios"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Let's add a comment explaining that we're using an iOS check here instead of an Android check
  2. Let's update the spacing to match native/vodozemac_bindings/src/lib.rs

Comment on lines 84 to 92
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()),
};
Copy link
Member

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.
Copy link
Member

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");
Copy link
Member

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");
Copy link
Member

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

Comment on lines 151 to 157
pub struct VodozemacAccount(pub(crate) vodozemac::olm::Account);

impl From<Account> for VodozemacAccount {
fn from(account: Account) -> Self {
VodozemacAccount(account)
}
}
Copy link
Member

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() {
Copy link
Member

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?

@xsanm xsanm force-pushed the vodozemac-work-part-4 branch from 865c668 to de66670 Compare December 3, 2025 16:53
) -> Result<Box<VodozemacSession>, String> {
let key_bytes = session_key.as_bytes();

//NOTE: vodozemac works only with 32-byte keys.
Copy link
Member

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
@xsanm xsanm force-pushed the vodozemac-work-part-4 branch from de66670 to de276f7 Compare December 3, 2025 16:58
@Ashoat Ashoat merged commit 6e81fde into vodozemac-work-part-3 Dec 3, 2025
Ashoat pushed a commit that referenced this pull request Dec 3, 2025
* [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
Ashoat pushed a commit that referenced this pull request Dec 3, 2025
…#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
@Ashoat Ashoat deleted the vodozemac-work-part-4 branch December 4, 2025 11:43
xsanm added a commit that referenced this pull request Dec 4, 2025
…#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants