← Back to the manual

Manual · Omni-Encryption

Python API

The classes you use from Python, what each one is for, and an example that ran on 2026-12-05.

What you use

NameWhat it is for
OmniKeyA random root key of 48 bytes. 384 bits is a key-derivation policy value; the effective symmetric strength is 256 bits.
OmniCipherOne end of a session. It encrypts and decrypts frames bound to a session, a direction and a sequence number, and uses the cascade by default.
PeerIdentityAn identity with X25519, ML-KEM-1024 and ML-DSA-87 keys. Its secret keys exist in memory only.
PeerPairTwo ends of a session in one process. create_authenticated runs the hybrid key exchange, and the pair rekeys automatically every 64 messages by default. It uses AES-256-GCM unless you pass aead_mode="cascade".
Second-layer adaptersWrap HTTP JSON bodies, agent RPC payloads, chat payloads, audit records and key-value values in an AES-256-GCM envelope once the layer is switched on and a key is configured.
Identity pin storeHolds the public keys of known peers: an explicit pin, trust on first use, or a pin tied to a validated TLS certificate. A known peer that presents a changed key is refused.

Example

This example ran on 2026-12-05. Both peers run in one process, and the caller holds both peers' private keys.

from aios_omni_encryption import OmniCipher, OmniKey, PeerIdentity, PeerPair

# 1) Two ends that already share a key, in one process.
key = OmniKey.generate()
sender = OmniCipher(key=key, session_id=b"0123456789abcdef")
receiver = OmniCipher(key=key, session_id=b"0123456789abcdef")
frame = sender.encrypt(b"hello", associated=b"demo")
print("frame bytes:", len(frame.blob), "| mode:", sender.aead_mode)
print("decrypted:", receiver.decrypt(frame, associated=b"demo"))

# 2) Two identities, the hybrid key exchange, then an exchange, in one process.
alice, bob = PeerIdentity.generate(), PeerIdentity.generate()
pair, handshake = PeerPair.create_authenticated(alice, bob, aead_mode="cascade")
print("a->b:", pair.alice_to_bob(b"hello bob", associated=b"demo"))
print("b->a:", pair.bob_to_alice(b"hello alice", associated=b"demo"))
frame bytes: 151 | mode: cascade
decrypted: b'hello'
a->b: b'hello bob'
b->a: b'hello alice'

The 5-byte message became a 151-byte frame: the cascade adds 146 bytes to each message, and AES-256-GCM alone adds 130.

Things to know

  • No network transport is provided.
  • Frames must arrive in order. A replayed, reordered, truncated or altered frame is rejected, and a rejected frame does not change the session's keys, epoch or sequence.
  • A bare OmniCipher refuses to send past its per-key message limit until a rekey is done. A PeerPair rekeys on its own.
  • Ciphertext length reveals plaintext length, because there is no padding.
  • The package is pure Python: in one process, encrypting and decrypting 1 KiB took about 0.11 ms on 2026-12-05 on a loaded host, about 24 times slower than raw AES-256-GCM. For bulk transfers of many gigabytes, use raw AES or TLS.

Documents for this section

  • Omni-Encryption spec sheet

    Spec sheet Omni-Encryption Version 0.8.0 2026-12-05

    Version 0.8.0, status Evaluation: interfaces, standard algorithms, sizes, measured timings with their date and conditions, what it checks and refuses, and what it does not do yet.

  • Omni-Encryption evaluation manual

    Manual Omni-Encryption Version 0.8.0 2026-12-05

    Requirements, how the package reaches a subscriber, a walk through the evaluation commands with what each prints, key handling and its warnings, switching on the second layer, the Python interface, and common problems.