Protect the message body with AES-256-GCM and ChaCha20-Poly1305
Authenticated encryption with associated data (AEAD) protects the message body so that only key holders can decrypt it. It also detects changes to the received data. In QuantAegis, Envelope derives the AEAD key and nonce from the KEM shared secret. You supply the body, the recipient, and any additional authenticated data (AAD), such as an order number.
How it works · AES-256-GCM encryption and tags · The ChaCha20 keystream and Poly1305
| SDK identifier | How it encrypts the body | How it detects changes |
|---|---|---|
aes-256-gcm | Uses AES with a 256-bit key in counter mode | Computes an authentication tag using GHASH |
chacha20-poly1305 | Combines the body with a keystream generated by ChaCha20 | Computes an authentication tag using Poly1305 |
Both algorithms use a 12-byte nonce and a 16-byte authentication tag in envelope v1. Both parties exchanging packets must support QuantAegis’s QAEN v1 format, including the header, key derivation, and AAD construction. The sender and recipient must supply matching AAD. Put confidential values in the body.
from quantaegis import Envelope
public_key, secret_key = Envelope.generate_keypair("x-wing")
packet = Envelope.seal(public_key, b"invoice", aead="chacha20-poly1305")
assert Envelope.open(secret_key, packet) == b"invoice"
Envelope format · NIST SP 800-38D (GCM) · RFC 8439 (ChaCha20-Poly1305)