python CFFI bindings for the olm cryptographic ratchet library
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install python-olmpython-olm
Python bindings for Olm.
The specification of the Olm cryptographic ratchet which is used for peer to peer sessions of this library can be found here.
The specification of the Megolm cryptographic ratchet which is used for group sessions of this library can be found here.
An example of the implementation of the Olm and Megolm cryptographic protocol can be found in the Matrix protocol for which the implementation guide can be found here.
The full API reference can be found here.
Installation instructions
To install from the source package, you will need:
- cmake (recommended) or GNU make
- a C/C++ compiler
You can then run pip install python-olm.
This should work in UNIX-like environments, including macOS, and may work in other environments too, but is known to not work yet in Windows.
Accounts
Accounts create and hold the central identity of the Olm protocol, they consist of a fingerprint and identity key pair. They also produce one time keys that are used to start peer to peer encrypted communication channels.
Account Creation
A new account is created with the Account class, it creates a new Olm key pair. The public parts of the key pair are available using the identity_keys property of the class.
>>> alice = Account()
>>> alice.identity_keys
{'curve25519': '2PytGagXercwHjzQETLcMa3JOsaU2qkPIESaqoi59zE',
'ed25519': 'HHpOuFYdHwoa54GxSttz9YmaTmbuVU3js92UTUjYJgM'}
One Time keys
One time keys need to be generated before people can start an encrypted peer to peer channel to an account.
>>> alice.generate_one_time_keys(1)
>>> alice.one_time_keys
{'curve25519': {'AAAAAQ': 'KiHoW6CIy905UC4V1Frmwr3VW8bTWkBL4uWtWFFllxM'}}
After the one time keys are published they should be marked as such so they aren't reused.
>>> alice.mark_keys_as_published()
>>> alice.one_time_keys
{'curve25519': {}}
Pickling
Accounts should be stored for later reuse, storing an account is done with the pickle method while the restoring step is done with the from_pickle class method.