Betanet Layer Prototype (L1, L2, L3, L5)
Quick prototype of Betanet layers L1, L2, L3, and L5 implemented as an asyncio simulation. This is for educational/demo purposes only — not production-ready code. If you don't now what it's all about, check out the following links for context:
- Developers, I need your help. I made a new internet - K0
- Explaining Betanet - K0
- The Betanet Specification
Disclaimer
This simulation does not use real Ed25519/X25519 cryptography. Crypto functions are stubbed with hash/HMAC placeholders to keep it simple and dependency-light.
For better implementations, replace the placeholder crypto in:
src/ashops.pysrc/betanet_cryptography.pysrc/htx_session.py
with real libraries like:
Mapping to the Betanet Spec
| Spec Layer | This Prototype Implements | Notes |
|---|---|---|
| L1 Path selection & AS-hop validation | Simple L1Path & PathSegment with ASHop objects signed by AS keys |
Validates SCION-like hop signatures |
| L2 Cover transport (HTX) | HTXSession with outer "fingerprint" mirroring & inner Noise-like handshake |
Frame types: STREAM, PING, KEY_UPDATE, CLOSE |
| L3 Overlay mesh | OverlayNode with peerstore & content exchange (bitswap-style) |
Simulates CID publication & retrieval |
| L5 Naming & trust | AliasLedger with self-certifying IDs & alias registration |
Includes expiry and sequence tracking |
Features
- Path building & validation (L1) — verifies AS hop signatures before use.
- HTX transport sessions (L2) — simulates TLS/QUIC-like outer wrapping with inner encrypted frames.
- Overlay network (L3) — publish & retrieve content by CID from connected peers.
- Alias ledger (L5) — map human-readable aliases to self-certifying IDs.
Running the Demo
# i have many mirrors thus the clone url might not match depending on where you
# are seeing this. but I have basically same everywhere so cloning github is ok.
git clone https://github.com/nishad-prime/betanet-layer-prototype.git
cd betanet-layer-prototype
python3 betanet_quick_impl.py
Expected output (trimmed for brevity):
[L1] Path validated
[L3] Carol published CID ab12cd34ef56...
[L5] Resolved carol.service -> deadbeefcafebabe...
[L3] Alice retrieved content via overlay: b"Hello from Carol's content!"
[L2][C] Received frame type=STREAM ...
...
Demo complete.
Directory Structure
.
|- betanet_quick_impl.py # Main asyncio simulation
|- src/
|- alias_ledger.py # L5 alias registry
|- ashop.py # L1 AS hop representation
|- betanet_cryptography.py # Simplified keypair/signature
|- htx_frame.py # HTX frame constants
|- htx_session.py # L2 HTX transport session
|- overlay_node.py # L3 overlay mesh node
|- path.py # L1 path building/validation
Next Steps
- Replace placeholder crypto with real Ed25519/X25519 implementations.
- Swap in a real routing library for L1.
- Expand L3 into a libp2p-compatible overlay.
- Add tests for path validation, alias expiry, and HTX frame parsing.
Languages
Python
100%