Skip to main content

OMEMO Double Ratchet

Project description

Initial codebase was forked from https://github.com/tgalal/python-axolotl but has since been heavily rewritten.

Dependencies

Linux

pip install .

Usage

This library handles only the crypto part of OMEMO, not the XMPP protocol part. This means you need to take care yourself of things like publishing/downloading bundles, publishing/subscribing to PEP deviceliste updates, sending and receiving messages.

Building a session

A OMEMO client needs to implement the Store interface (omemo_dr.state.store.Store). This will manage loading and storing of identity, prekeys, signed prekeys, and session state.

Once this is implemented, building a session is fairly straightforward:

storage = MyStorage()

config = OMEMOConfig(default_prekey_amount=100,
                     min_prekey_amount=80,
                     spk_archive_seconds=86400 * 15,
                     spk_cycle_seconds=86400,
                     unacknowledged_count=2000)

manager = OMEMOSessionManager(address, storage, config)

# Get your bundle for publishing
bundle = manager.get_bundle('eu.siacs.conversations.axolotl')
my_publish_method(bundle)

# Build a session with a downloaded bundle of a remote contact
bundle = my_receive_bundle_method()
manager.build_session(remote_address, bundle)

# Encrypt a message to a remote contact
message = manager.encrypt(remote_address, plaintext)
my_send_message_method(message)

# Descrypt a message
message = my_receive_message_method()
plaintext, fingerprint, trust = manager.decrypt(message, remote_address)

Development

Generating protobuf files

Download the protobuf-compiler > 3.19 and execute

$ protoc -I=src/omemo_dr/protobuf --python_out=src/omemo_dr/protocol omemo.proto whisper.proto
$ protoc -I=src/omemo_dr/protobuf --python_out=src/omemo_dr/state storage.proto

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omemo_dr-1.2.0.tar.gz (152.8 kB view details)

Uploaded Source

File details

Details for the file omemo_dr-1.2.0.tar.gz.

File metadata

  • Download URL: omemo_dr-1.2.0.tar.gz
  • Upload date:
  • Size: 152.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for omemo_dr-1.2.0.tar.gz
Algorithm Hash digest
SHA256 18b6542b3bb7ed6dce34dd02f32b16401982ba24f0146ddae091dcb92c79a484
MD5 9212952fb7a4f428c6ca0cfa5650b2b6
BLAKE2b-256 4f6c2e024e615cca6f5e03261cf8fa9f584a5ecd59d3fb7ac7e7bf52f2d9cee1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page