Skip to content
refcellPublic

About

some zig components

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

zigware

Zig Platform Dependencies Status License

zigware is the Commonware Library rewritten from scratch in Zig: codec, cryptography, a deterministic runtime, storage, authenticated p2p, broadcast, and BFT consensus, with zero dependencies.

It is a ground-up port of the public commonware monorepo and keeps its layout: every crate there is a package here with the same name and the same dependency graph, and wire formats are byte-identical so the two can interoperate.

The estimator simulates a Simplex round across three AWS regions

The estimator runs a consensus protocol written in a small DSL over the deterministic runtime and the simulated p2p network, with real AWS inter-region latencies, and reports when each region crosses each step (video). Here Simplex finalizes across seven validators in three regions in about 114 ms at the mean. zig build run-estimator -- <file.lazy> --distribution <region:count,...> runs any protocol in examples/estimator.

Four flood peers exchange messages over authenticated p2p on real TCP

flood runs four peers as separate processes on real TCP sockets. They find each other through authenticated p2p discovery, encrypt every connection, and send each other random messages as fast as the network accepts them. Each peer prints its throughput and latency every 2 s (video): about 620 messages per second per peer at around 1 ms mean latency. etc/scripts/record-demo.sh flood runs it locally.

Three chat peers exchange encrypted messages over authenticated p2p

chat is an encrypted group chat between friends who know each other's public keys. Here three peers run as separate processes on the production runtime, connect through authenticated p2p discovery, and trade messages; each terminal shows the conversation, the peer's live metrics, and its logs, where p2p discovery reports its handshakes and peer updates under commonware's event names (video). etc/scripts/record-demo.sh chat records it again.

Four validators run Simplex consensus and finalize blocks over real TCP

log runs Simplex BFT consensus across four validators, each a separate process on the production runtime connected through authenticated p2p discovery. Every validator proposes random payloads in turn and shows when each view is proposed (blue), notarized, and finalized (green), keeping its consensus journal on disk so a restarted validator resumes where it left off. The Logs panes stream the voter's tracing events as it broadcasts votes, recovers certificates, and prunes old views (video). etc/scripts/record-demo.sh log records it again.

Warning

zigware is pre-alpha and being ported now. Do not use it in production.

Packages

Package What it does Status
codec Serialize structured data ported
cryptography Keys, signatures, hashes, BLS12-381 threshold crypto porting
math Fields, polynomials, NTT porting
runtime Async tasks with a deterministic scheduler or io_uring porting
storage Journals, archives, MMRs, authenticated databases porting
utils Shared functionality across primitives ported
parallel Parallel folds with pluggable strategies ported
actor Coordinate concurrent components ported
stream Encrypted messages over any transport ported
p2p Communicate with authenticated peers porting
broadcast Disseminate data over a wide-area network ported
resolver Resolve data by a fixed-length key ported
collector Collect responses to committable requests ported
coding Erasure-code data for recovery from fragments ported
clearing Settle actions at scale porting
consensus Order messages in a Byzantine environment (simplex, aggregation, marshal) porting
glue Default constructions spanning several primitives porting
deployer Deploy infrastructure across cloud providers porting

Support packages: formatting, conformance, invariants, simd, allocator, bench. docs/ARCHITECTURE.md maps every commonware crate to its package and lists the dependency order.

Design

  • Zero dependencies. Only the Zig standard library: no C libraries, no vendored code, build.zig.zon has an empty .dependencies. BLS12-381, ed25519, secp256r1, the hashes, Reed-Solomon, the runtime, and the storage engines are all implemented here.
  • Same wire formats. Encodings, storage layouts, and network messages match commonware's byte for byte, checked against commonware's own test vectors and conformance hashes.
  • Deterministic simulation testing. All time, randomness, tasks, network, and storage go through the runtime. The deterministic runtime runs real protocol code on a simulated network with fault injection, and any run replays exactly from its seed.
  • TigerStyle. Assertions on every precondition, postcondition, and invariant; every loop, queue, and mailbox bounded; no recursion; functions ≤ 70 lines. See docs/TIGER_STYLE.md.
  • Fuzzed. Every decoder, parser, and state machine has a coverage-guided fuzz target and a seeded fuzz run that executes with the normal test suite.
  • io_uring. The production runtime is completion-based IO on Linux, kqueue on macOS.

Installation

git clone https://github.com/refcell/zigware && cd zigware
just release

just release needs just and curl. It uses Zig 0.17.1 from PATH, or downloads it into .cache/zig, and writes optimized binaries to zig-out/bin. zigware has no other build dependency. There are no tagged releases; build from main.

Use a package from your own build.zig through the zigware module, or one package by name (b.dependency("zigware", .{}).module("codec")).

Contributing

just lists every development recipe. zig build test runs every package's tests and zig build test-<package> runs one. Contributor rules are in AGENTS.md; the port's work split is in docs/lanes and docs/ROADMAP.md.

License

MIT. zigware is a port of the Commonware Library, which is dual-licensed under MIT and Apache 2.0.

About

some zig components

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages