Claude 24f816b6a3
Consolidate 22 sibling repos into layered organism structure
Place useful parts of the surrounding repos into sica-fondt by layer, per the
body model (Ada = membrane; brain/endocrine/capabilities/knowledge non-Ada):

- brain/        LLM reasoning + providers (dapr, hermes, MoMoA)
- capabilities/ REPRAG sidecars: hermes tools/skills, dapr tools, parallel
                dispatch, A51 channels, and the OSINT cluster
- knowledge/    LORAG corpus: 754 cyber-skills, agency personas, secure-coding,
                MITRE ATT&CK data
- reference/    defensive threat-reference (C3, shhbruh doc) + AdaYaml parser

License handling: AGPL sources (worldosint, advanced_evolution, mercury,
Reticulum) and GPL DeTTECT are SPEC-only clean-room/port descriptions — no
copyleft code copied. MIT/Apache/data parts copied as working trees.

Safety: shhbruh escape/persistence material and C3 covert-C2 kept as reference
only, not wired into the running organism. See CONSOLIDATION.md.

https://claude.ai/code/session_01UehUqEXXJJCsHoA4voCU5c
2026-06-10 06:53:01 +00:00

49 lines
1.8 KiB
Markdown

# API Reference — Implementing End-to-End Encryption for Messaging
## Libraries Used
- **cryptography**: X25519 key exchange, HKDF key derivation, AES-256-GCM encryption
## CLI Interface
```
python agent.py keygen # Generate X25519 key pair
python agent.py exchange # Simulate key exchange
python agent.py demo # Full E2EE demo flow
python agent.py encrypt --message <text> --key <hex> # Encrypt message
python agent.py decrypt --nonce <hex> --ciphertext <hex> --key <hex>
```
## Core Functions
### `generate_keypair()`
Generates X25519 key pair for Diffie-Hellman key exchange.
- `X25519PrivateKey.generate()` -> private key
- `private_key.public_key()` -> public key
- Returns hex-encoded private and public keys.
### `derive_shared_secret(my_private_hex, their_public_hex)`
Performs X25519 ECDH key exchange and derives symmetric key via HKDF-SHA256.
- `my_private.exchange(their_public)` -> 32-byte raw shared secret
- `HKDF(algorithm=SHA256(), length=32, info=b"e2ee-messaging-v1").derive(shared)`
### `encrypt_message(message, shared_key_hex)`
Encrypts plaintext using AES-256-GCM with random 12-byte nonce.
- `AESGCM(key).encrypt(nonce, plaintext, None)` -> ciphertext with GCM tag
### `decrypt_message(nonce_hex, ciphertext_hex, shared_key_hex)`
Decrypts and authenticates ciphertext. Raises `InvalidTag` if tampered.
## Cryptography API Calls
| Class | Module | Purpose |
|-------|--------|---------|
| `X25519PrivateKey` | `cryptography.hazmat.primitives.asymmetric.x25519` | ECDH private key |
| `X25519PublicKey` | same | ECDH public key |
| `AESGCM` | `cryptography.hazmat.primitives.ciphers.aead` | Authenticated encryption |
| `HKDF` | `cryptography.hazmat.primitives.kdf.hkdf` | Key derivation |
## Dependencies
```
pip install cryptography>=41.0
```