Add Python Attribute Accessors for PkEncryption#15
Add Python Attribute Accessors for PkEncryption#15PaarthShah merged 16 commits intomatrix-nio:mainfrom
Conversation
Adds python-olm Dependencie (at 3.2.16). Adds PkEncryption (python-olm) compatibility tests.
poljar
left a comment
There was a problem hiding this comment.
Thanks for writing this and sorry for the delay here. I left some small nits.
Adds a to_base64 conversion message method.
Removes base64 padding conversion helper functions from tests.
poljar
left a comment
There was a problem hiding this comment.
Some two minor things left to do, then I think we can merge.
Adds PkDecodeException test case
poljar
left a comment
There was a problem hiding this comment.
Great, I think this is good to go functionality-wise.
Could you just fix the formatting you'll have to use rustmfmt nightly for this:
$ cargo +nightly fmtCo-authored-by: Damir Jelić <poljar@termina.org.uk>
|
Hey @poljar The CI/CD Error appears to be a known issue – libolm cannot be built on Windows easily (see matrix-org/olm#25). Given its deprecation, I don’t expect Windows support to ever be added. Skipping all Windows tests might be overkill. Instead, we could skip the libolm tests via pytest options and ignore them to avoid import errors. One option is to create a separate requirements file (e.g. requirements-dev-win.txt); another option is to dynamically modify the requirements-dev.txt file in the noxfile by removing the libolm dependency (a bit hacky tho). For example: import nox
import os
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def test(session):
if os.name == 'nt': # Check if the OS is Windows
session.log("Skipping libolm tests on Windows due to known issues.")
# Option 1: Use a separate requirements file (requirements-dev-win.txt)
# Option 2: Dynamically remove the "python-olm==3.2.16" dependency from requirements-dev.txt
session.install("-r requirements-dev-win.txt")
session.install("-e", ".", "--no-build-isolation")
session.run("pytest --ignore=tests/pk_encryption_test.py")
return
session.install("-r requirements-dev.txt")
session.install("-e", ".", "--no-build-isolation")
session.run("pytest")What do you think? Or you may even have a better idea? |
|
I would add to the requirements file. |
|
Hey @guywithface, |
|
@TrevisGordan I'm going to start handling this; feel free to message me directly as-desired |
PaarthShah
left a comment
There was a problem hiding this comment.
I'm going to make a decisive stance; given that python-olm no longer compiles even on linux (see matrix-nio/matrix-nio#541 (comment)) (nor macos and windows), and given the official stance that the library is deprecated, I'll go ahead and say that compatibility between the libraries is no longer a useful goal of vodozemac-python (though it was a very noble effort and it would've been cool if it worked).
As such, I think we can get away with removing those tests outright. I've pushed changes to the branch to this effect; if you and @poljar are good for it, then so am I. But I can't get python-olm to install anymore, and I'm really over it
Sounds sensible to me. |
|
LGTM Thanks Guys! |
This PR adds missing Python attribute accessors
and improves compatibility with python-olm by enabling cross-library encryption and decryption tests.Details:
#[pyo3(get)]annotations to theMessagestruct fields (ciphertext,mac,ephemeral_key), making these attributes accessible from Python.Messageconstructor in Rust (via#[new]), allowing Python code to createMessageinstances directly.Adds integration tests to ensure:PkEncryptionis compatible with python-olm. SpecificallyEncrypt with Olm and decrypt with Vodozemac.Encrypt with Vodozemac and decrypt with Olm.Next Steps:
To achieve seamless compatibility, the user will need to Base64-encode Vodozemac message attributes (ciphertext, mac, ephemeral_key) before passing them to Olm. For example:A future enhancement could add a Rust helper function to handle this encoding automatically, such as:
Also
unpad_base64_encodeandpad_base64_decodefunctions.This would streamline the process and reduce the amount of Python-side encoding logic required.