Commit Graph

7 Commits

Author SHA1 Message Date
Voxis 8f86a32eee fix(build): resolve Zig module conflicts - capsule binary now compiles
- Changed file-level imports to module imports throughout codebase
- Added missing module imports to l1_mod (soulkey, time, trust_graph, qvl)
- Added l0_mod.addImport("time", time_mod) for l0-transport
- Fixed API calls in examples to match current encryptPayload/decryptPayload signatures
- Fixed namespace references in capsule code (l0_transport.lwf → l0_transport)
- Removed redundant soulkey import from capsule_mod
- Capsule binary: 29MB debug build, verified working

Build Status:  PASS (all artifacts compile successfully)
Tests: zig build completes successfully
2026-02-16 04:24:55 +01:00
Markus Maiwald 5a79e02684
fix(test_pqxdh): implement real Ed25519 signature generation/validation
Replace stubbed signed_prekey_signature = [0] ** 64 with real Ed25519
cryptographic signatures. This fixes the security-critical signature
validation that was previously bypassed in tests.

Changes:
- Add signEd25519() helper for deterministic Ed25519 signing
- Add verifyEd25519() helper for signature verification
- Generate real identity keypair for Bob (Ed25519)
- Sign Bob's X25519 signed_prekey with his Ed25519 identity key
- Verify signature before using prekey in handshake
- Add dedicated test for Ed25519 signature roundtrip

Security: Prekey bundles now carry cryptographic proof of authenticity.
The signature binds the medium-term signed prekey to the long-term
identity key, preventing MITM attacks during key exchange.

Fixes P0 security audit issue: Stubbed Signature Validation
(closes issue at test_pqxdh.zig:113)
2026-02-09 00:56:02 +01:00
Markus Maiwald bdfb0b2775
fix(crypto): add AAD to AEAD encryption binding ciphertext to context
Previously encryptPayload() used empty AAD, allowing ciphertext to be
replayed across different contexts. Now includes header fields as AAD:

- ephemeral_pubkey: Binds to sender identity
- timestamp: Replay protection (5 min window)
- service_type: Context binding (WORLD/FEED/MESSAGE/DIRECT)

API changes:
- encryptPayload() now requires service_type parameter
- decryptPayload() now requires expected_service_type parameter
- EncryptedPayload extended with timestamp and service_type fields
- New error types: ServiceTypeMismatch, TimestampTooOld, TimestampInFuture

Security: Ciphertext is now cryptographically bound to sender,
timestamp, and service context. Replay and context confusion attacks
are prevented via AAD verification during decryption.

Fixes P0 security audit issue: Missing AAD in AEAD Encryption
2026-02-09 00:55:34 +01:00
Markus Maiwald ac47f8ddf4
fix(pqxdh): add compile-time feature gating for liboqs
Add build option -Denable-liboqs to conditionally enable post-quantum crypto.
When disabled, uses liboqs_stub.zig which provides stub implementations
that return ML_KEM_NotAvailable error.

Changes:
- build.zig: Add enable_liboqs option and liboqs module selection
- pqxdh.zig: Use liboqs.isAvailable() runtime check for PQ operations
- soulkey.zig: Use pqxdh.enable_pq to conditionally generate ML-KEM keys
- liboqs_stub.zig: Stub implementations when liboqs not linked
- liboqs_real.zig: Real C FFI bindings when liboqs is linked

Fixes P0 security audit issue: liboqs Build Breakage
2026-02-09 00:55:11 +01:00
Markus Maiwald 0f0f1a4d57
fix(build): resolve module import issues post-refactor
Fix circular and missing module imports across L0-L2 layers:
- Add l0_transport import to QVL and PoP modules in build.zig
- Fix gateway test to use DhtService parameter
- Convert l0_transport imports to direct time imports in L1
- Fix soulkey to use module import (@import("pqxdh"))
- Fix policy.zig to use module import (@import("lwf"))
- Refactor mod.zig exports to avoid circular dependencies
- Update service.zig and utcp/socket.zig to use module imports
- Fix all QVL test files to import time directly

Results: 254+ tests passing (was 124), 1 module conflict remaining
in service tests (opq/store.zig in both lwf and opq modules).

Refs: Night Sprint 2026-02-05
2026-02-05 22:17:11 +01:00
Markus Maiwald 0a86a93cf5
refactor: complete repository restructure with tiered licensing
BREAKING CHANGE: Repository restructured from flat layout to tiered:

FOLDER REORGANIZATION:
- core/          - L0-L3 layers (Commonwealth LCL-1.0)
  - l0-transport/   - Transport with MIMIC, Noise, PNG
  - l1-identity/    - Identity, QVL, Crypto
  - l2_session/     - Session management
  - l2-federation/  - Cross-chain bridging
  - l2-membrane/    - Policy enforcement
- sdk/           - L4+ and bindings (Sovereign LSL-1.0)
  - janus-sdk/
  - l4-feed/
- apps/          - Examples (Unbound LUL-1.0)
  - examples/
- legal/         - All license texts
  - LICENSE_COMMONWEALTH.md
  - LICENSE_SOVEREIGN.md
  - LICENSE_UNBOUND.md

IMPORT FIXES (All Layers):
- L0: 13 files fixed - all relative imports corrected
- L1: 14 files fixed - module imports for cross-layer dependencies
- L2: 6 files fixed - session, membrane, federation
- Capsule: 9 files fixed - TUI, node, main, control
- Examples: 2 files fixed - lwf, crypto

LICENSES ADDED:
- LCL-1.0: Viral reciprocity for Core (SaaS-proof)
- LSL-1.0: Business-friendly for SDK
- LUL-1.0: Maximum freedom for docs/apps

NO CLA REQUIRED - contributors keep copyright

README.md REWRITTEN:
- Documents new folder structure
- Explains tiered licensing strategy
- Clear SPDX identifiers per component

TODO:
- Fix remaining test module configuration issues
- Full green build in follow-up

Refs: 4 sub-agents parallel execution
2026-02-05 21:50:54 +01:00
Markus Maiwald 07ccd484f1
refactor: restructure repository with tiered licensing
Major restructuring of libertaria-sdk -> libertaria-stack:

FOLDER REORGANIZATION:
- core/          - L0-L3 layers (Commonwealth LCL-1.0)
  - l0-transport/
  - l1-identity/
  - l2_session/
  - l2-federation/
  - l2-membrane/
- sdk/           - L4+ and bindings (Sovereign LSL-1.0)
  - janus-sdk/
  - l4-feed/
- apps/          - Examples (Unbound LUL-1.0)
  - examples/
- legal/         - All license texts

LICENSES ADDED:
- LICENSE_COMMONWEALTH.md (LCL-1.0) - Viral reciprocity for Core
- LICENSE_SOVEREIGN.md (LSL-1.0) - Business-friendly for SDK
- LICENSE_UNBOUND.md (LUL-1.0) - Maximum freedom for docs/apps

BUILD.ZIG UPDATED:
- All paths updated to new structure
- Examples imports fixed

README.md REWRITTEN:
- Documents new folder structure
- Explains tiered licensing strategy
- Clear SPDX identifiers per component

NO CLA REQUIRED - contributors keep copyright
2026-02-05 20:12:32 +01:00