Initial codebase was forked from https://github.com/tgalal/python-axolotl
This is a python port of libsignal-protocol-java originally written by Moxie Marlinspike
Dependencies
Linux
pip install .
Usage
This python port is done in an almost 1:1 mapping to the original java code. Therefore any original documentation for the java code can be easily mapped and used with this python port.
Install time
At install time, a libaxolotl client needs to generate its identity keys, registration id, and prekeys.
identityKeyPair = KeyHelper.generateIdentityKeyPair()
registrationId = KeyHelper.generateRegistrationId()
preKeys = KeyHelper.generatePreKeys(startId, 100)
lastResortKey = KeyHelper.generateLastResortKey()
signedPreKey = KeyHelper.generateSignedPreKey(identityKeyPair, 5)
#Store identityKeyPair somewhere durable and safe.
#Store registrationId somewhere durable and safe.
#Store preKeys in PreKeyStore.
#Store signed prekey in SignedPreKeyStore.
Building a session
A libaxolotl client needs to implement four interfaces: IdentityKeyStore, PreKeyStore, SignedPreKeyStore, and SessionStore. These will manage loading and storing of identity, prekeys, signed prekeys, and session state.
Once those are implemented, building a session is fairly straightforward:
sessionStore = MySessionStore()
preKeyStore = MyPreKeyStore()
signedPreKeyStore = MySignedPreKeyStore()
identityStore = MyIdentityKeyStore()
# Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
sessionBuilder = SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityStore, recipientId, deviceId)
# Build a session with a PreKey retrieved from the server.
sessionBuilder.process(retrievedPreKey)
sessionCipher = SessionCipher(sessionStore, recipientId, deviceId)
message = sessionCipher.encrypt("Hello world!")
deliver(message.serialize())
Development
Generating protobuf files
Download the protobuf-compiler and execute
protoc -I=omemo_dr/protobuf --python_out=omemo_dr/protobuf OMEMO.proto WhisperTextProtocol.proto LocalStorageProtocol.proto
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file omemo-dr-0.99.0.tar.gz.
File metadata
- Download URL: omemo-dr-0.99.0.tar.gz
- Upload date:
- Size: 155.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79f9b166b350b3baced2bb0a998a3f8a3cf8756b5b5714d08c5cee5c90e62a8e
|
|
| MD5 |
71b6f2e0505b2ad42fc41b959d32b713
|
|
| BLAKE2b-256 |
ca3635ffe5e84134e01b16ec6086ace350297ea0755315707d99145db55f152e
|