Implement XNet in Your Language
You don’t need to port the whole xNet codebase to build a compatible
implementation. You need the interop kernel (L0 + L1) — and the
golden vectors tell you exactly when you’ve got it
right.
The path
Section titled “The path”-
Identity —
did:keyover Ed25519. Generate an Ed25519 key, prefix the public key with multicodec0xed 0x01, base58btc‑encode, prependdid:key:z. Check againstconformance/vectors/identity/. -
Canonicalize a change. Sort keys lexicographically and recursively, serialize to compact UTF‑8 JSON. Check against the
canonicalJsonfield inconformance/vectors/change/. -
Hash & sign.
"cid:blake3:" + hex(BLAKE3(bytes)), then Ed25519‑sign the UTF‑8 bytes of that hash string. ReproducehashandsignatureBase64. -
Last‑Write‑Wins. Fold a change sequence with per‑property
{lamport, wallTime, authorDID}resolution (higher wins, author breaks ties). Check againstconformance/vectors/lww/. -
(Optional) Replication & authorization. Implement the wire messages and policy evaluation to join live rooms.
The kernel, in ~30 lines
Section titled “The kernel, in ~30 lines”This is the entire L0 + L1 verify path in Python — proof that the spec, not the TypeScript source, is enough to interoperate:
import base64, json, base58from blake3 import blake3from nacl.signing import SigningKey, VerifyKey
ED25519_MULTICODEC = b"\xed\x01"
def did_from_public_key(pub: bytes) -> str: # L0 §1 return "did:key:z" + base58.b58encode(ED25519_MULTICODEC + pub).decode()
def canonical_json(value) -> bytes: # L1 §6 return json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode("utf-8")
def change_hash(unsigned: dict) -> str: # L1 §6 to_hash = {k: v for k, v in unsigned.items() if k != "protocolVersion"} \ if unsigned.get("protocolVersion", 0) in (0, None) else unsigned return "cid:blake3:" + blake3(canonical_json(to_hash)).hexdigest()
def verify_change(unsigned: dict, sig: bytes, pub: bytes) -> bool: try: VerifyKey(pub).verify(change_hash(unsigned).encode(), sig); return True except Exception: return FalseRun the proof
Section titled “Run the proof”git clone https://github.com/crs48/xNet && cd xNetpip install pynacl blake3 base58python conformance/reference/python/verify_vectors.py# → 18 passed, 0 failedClaim conformance
Section titled “Claim conformance”Reproduce a layer’s golden vectors byte‑for‑byte, then open a PR adding a row to the conformance matrix. Proposing a change to the protocol itself? File an XPP — the lightweight, “prove‑it‑before‑you‑spec‑it” proposal process.