diff --git a/build.zig b/build.zig index 94784f0..4454b7b 100644 --- a/build.zig +++ b/build.zig @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void { // L0: Transport Layer // ======================================================================== const l0_mod = b.createModule(.{ - .root_source_file = b.path("l0-transport/lwf.zig"), + .root_source_file = b.path("l0-transport/mod.zig"), .target = target, .optimize = optimize, }); @@ -134,7 +134,7 @@ pub fn build(b: *std.Build) void { // L1: Identity & Crypto Layer // ======================================================================== const l1_mod = b.createModule(.{ - .root_source_file = b.path("l1-identity/crypto.zig"), + .root_source_file = b.path("l1-identity/mod.zig"), .target = target, .optimize = optimize, }); diff --git a/l0_transport.zig b/l0-transport/mod.zig similarity index 51% rename from l0_transport.zig rename to l0-transport/mod.zig index b31a04f..070fd01 100644 --- a/l0_transport.zig +++ b/l0-transport/mod.zig @@ -1,19 +1,19 @@ const std = @import("std"); // Re-export LWF (Libertaria Wire Frame) -pub const lwf = @import("l0-transport/lwf.zig"); +pub const lwf = @import("lwf.zig"); // Re-export Time primitives -pub const time = @import("l0-transport/time.zig"); +pub const time = @import("time.zig"); // Re-export UTCP (UDP Transport) -pub const utcp = @import("l0-transport/utcp.zig"); +pub const utcp = @import("utcp/utcp.zig"); // Re-export OPQ (Offline Packet Queue) -pub const opq = @import("l0-transport/opq.zig"); +pub const opq = @import("opq.zig"); // Re-export Integrated Service (UTCP + OPQ) -pub const service = @import("l0-transport/service.zig"); +pub const service = @import("service.zig"); test { std.testing.refAllDecls(@This()); diff --git a/l1-identity/mod.zig b/l1-identity/mod.zig new file mode 100644 index 0000000..85620b4 --- /dev/null +++ b/l1-identity/mod.zig @@ -0,0 +1,17 @@ +const std = @import("std"); + +// Re-export Identity modules +pub const did = @import("did.zig"); +pub const soulkey = @import("soulkey.zig"); +pub const qvl = @import("qvl.zig"); +pub const qvl_ffi = @import("qvl_ffi.zig"); +pub const entropy = @import("entropy.zig"); +pub const crypto = @import("crypto.zig"); +pub const argon2 = @import("argon2.zig"); +pub const pqxdh = @import("pqxdh.zig"); +pub const prekey = @import("prekey.zig"); +pub const slash = @import("slash.zig"); + +test { + std.testing.refAllDecls(@This()); +} diff --git a/l1_identity.zig b/l1_identity.zig deleted file mode 100644 index a44ae7e..0000000 --- a/l1_identity.zig +++ /dev/null @@ -1,17 +0,0 @@ -const std = @import("std"); - -// Re-export Identity modules -pub const did = @import("l1-identity/did.zig"); -pub const soulkey = @import("l1-identity/soulkey.zig"); -pub const vector = @import("l1-identity/vector.zig"); -pub const trust_graph = @import("l1-identity/trust_graph.zig"); -pub const proof_of_path = @import("l1-identity/proof_of_path.zig"); -pub const entropy = @import("l1-identity/entropy.zig"); -pub const crypto = @import("l1-identity/crypto.zig"); -pub const argon2 = @import("l1-identity/argon2.zig"); -pub const pqxdh = @import("l1-identity/pqxdh.zig"); -pub const prekey = @import("l1-identity/prekey.zig"); - -test { - std.testing.refAllDecls(@This()); -} diff --git a/l2_session.zig b/l2_session.zig deleted file mode 100644 index 600ad37..0000000 --- a/l2_session.zig +++ /dev/null @@ -1,101 +0,0 @@ -//! Sovereign Index: L2 Session Manager -//! -//! The L2 Session Manager provides cryptographically verified, -//! resilient peer-to-peer session management for the Libertaria Stack. -//! -//! ## Core Concepts -//! -//! - **Session**: A sovereign state machine representing trust relationship -//! - **Handshake**: PQxdh-based mutual authentication -//! - **Heartbeat**: Cooperative liveness verification -//! - **Rotation**: Seamless key material refresh -//! -//! ## Transport -//! -//! This module uses QUIC and μTCP (micro-transport). -//! WebSockets are explicitly excluded by design (ADR-001). -//! -//! ## Usage -//! -//! ```janus -//! // Establish a session -//! let session = try l2_session.establish( -//! peer_did: peer_identity, -//! ctx: ctx -//! ); -//! -//! // Send message through session -//! try session.send(message, ctx); -//! -//! // Receive with automatic decryption -//! let response = try session.receive(timeout: 5s, ctx); -//! ``` -//! -//! ## Architecture -//! -//! - State machine: Explicit, auditable transitions -//! - Crypto: X25519Kyber768 hybrid (PQ-safe) -//! - Resilience: Graceful degradation, automatic recovery - -const std = @import("std"); - -// Public API exports -pub const Session = @import("l2_session/session.zig").Session; -pub const State = @import("l2_session/state.zig").State; -pub const Handshake = @import("l2_session/handshake.zig").Handshake; -pub const Heartbeat = @import("l2_session/heartbeat.zig").Heartbeat; -pub const KeyRotation = @import("l2_session/rotation.zig").KeyRotation; -pub const Transport = @import("l2_session/transport.zig").Transport; - -// Re-export core types -pub const SessionConfig = @import("l2_session/config.zig").SessionConfig; -pub const SessionError = @import("l2_session/error.zig").SessionError; - -/// Establish a new session with a peer -/// -/// This initiates the PQxdh handshake and returns a session in -/// the `handshake_initiated` state. The session becomes `established` -/// after the peer responds. -pub fn establish( - peer_did: []const u8, - config: SessionConfig, - ctx: anytype, -) !Session { - return Handshake.initiate(peer_did, config, ctx); -} - -/// Resume a previously established session -/// -/// If valid key material exists from a previous session, -/// this reuses it for fast re-establishment. -pub fn resume( - peer_did: []const u8, - stored_session: StoredSession, - ctx: anytype, -) !Session { - return Handshake.resume(peer_did, stored_session, ctx); -} - -/// Accept an incoming session request -/// -/// Call this when receiving a handshake request from a peer. -pub fn accept( - request: HandshakeRequest, - config: SessionConfig, - ctx: anytype, -) !Session { - return Handshake.respond(request, config, ctx); -} - -/// Process all pending session events -/// -/// Call this periodically (e.g., in your event loop) to handle -/// heartbeats, timeouts, and state transitions. -pub fn tick( - sessions: []Session, - ctx: anytype, -) void { - for (sessions) |*session| { - session.tick(ctx); - } -} diff --git a/l2_session/mod.zig b/l2_session/mod.zig new file mode 100644 index 0000000..65ce910 --- /dev/null +++ b/l2_session/mod.zig @@ -0,0 +1,21 @@ +//! Sovereign Index: L2 Session Manager +//! +//! The L2 Session Manager provides cryptographically verified, +//! resilient peer-to-peer session management for the Libertaria Stack. + +const std = @import("std"); + +// Public API exports +pub const Session = @import("session.zig").Session; +pub const State = @import("state.zig").State; +pub const Handshake = @import("handshake.zig").Handshake; +pub const Heartbeat = @import("heartbeat.zig").Heartbeat; +pub const KeyRotation = @import("rotation.zig").KeyRotation; + +// Re-export core types +pub const SessionConfig = @import("config.zig").SessionConfig; +pub const SessionError = @import("error.zig").SessionError; + +test { + std.testing.refAllDecls(@This()); +}