Skip to content

Commit 4b0b154

Browse files
committed
feat(coord-fed): Phase 1.2 — Zig coord_identity.zig + 4 FFI exports
ADR-0016 Phase 1.2. Realises the C-ABI contract documented in LocalCoord.Identity: boj_coord_identity_init(key_path) — generate-or-load seed, persist at 0600 boj_coord_identity_get_pubkey(out, out_len) — 32B pubkey export boj_coord_identity_load_known_peers(toml) — load trust list boj_coord_identity_known_peer_count() — count of loaded peers * coord_identity.zig new file alongside coord_durability.zig — keeps the identity surface isolated from the main coord state machine. Singleton process state guarded by a mutex; no allocator threading needed for Phase 1's fixed-size known-peers array (cap = 64). * std.crypto.sign.Ed25519.KeyPair.generateDeterministic for seed → keypair derivation (Zig 0.15.x API). Honest error propagation on the (essentially-impossible) IdentityElementError path. * Minimal hand-rolled TOML-shaped parser for known_peers.toml — no third-party dep, parses [[peer]] blocks with id/pubkey/host/port fields. Unknown keys silently ignored (forward-compat). Missing file is 0 entries, not an error, so the bus starts cleanly on first run before any trust has been established. * local_coord_ffi.zig adds `comptime { _ = @import("coord_identity.zig") }` so the new pub-export-fn symbols are linked into the shared library without a circular dependency or restructure of the main FFI file. * Zig tests in-file (FFI roundtrip, hex decode positive/negative, TOML single/multi-block, missing-field rejection, missing-file load_known_peers). `zig build test` picks them up via the module import; no build.zig change needed. NOT compiled locally — zig is devShell-only in this dev environment (no `nix` either). API choices kept conservative for Zig 0.15.x (splitScalar over splitAny, .public_key.bytes field access over .toBytes()). CI's e2e workflow installs Zig 0.15.1 and will catch any mismatch.
1 parent b809317 commit 4b0b154

2 files changed

Lines changed: 443 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)