๐ How Hyphanet (Freenet) Decouples Content from Origin Servers
Unlike Tor and I2Pโwhich route live connections between a client and an active host serverโHyphanet (formerly Freenet 0.7) operates as a censorship-resistant, peer-to-peer distributed encrypted datastore. Files and static sites (Freesites) are split into encrypted chunks, replicated across participating nodes based on 1D circular keyspace proximity, and retrieved even after the original publisher goes offline.
1. Example 1: Tor / I2P Live Routing vs. Hyphanet Datastore Architecture
Compare live stream-tunnel overlays (Tor and I2P) against Hyphanet's content-addressed, asynchronous distributed storage model.
Python (architecture_compare.py)
models = [
("Network Model", "Tor: Circuit-switched proxy", "Hyphanet: Distributed P2P datastore"),
("Publisher Online?", "Required (live Rendezvous)", "Not required once blocks propagate"),
("Addressing Scheme", "56-char Ed25519 .onion host", "Cryptographic keys (CHK/SSK/USK/KSK)"),
("Topology Modes", "Public consensus relay network", "Darknet (friend-to-friend) & Opennet"),
("Data Persistence", "Ephemeral session streams", "LRU cache + pinned local datastore"),
("Client Protocol", "SOCKS5 / ControlPort (9050/51)", "Freenet Client Protocol FCPv2 (9481)")
]
for attr, tor_desc, hypha_desc in models:
print(f"{attr:<18} | {tor_desc:<31} | {hypha_desc}")
Output:
Network Model | Tor: Circuit-switched proxy | Hyphanet: Distributed P2P datastore
Publisher Online? | Required (live Rendezvous) | Not required once blocks propagate
Addressing Scheme | 56-char Ed25519 .onion host | Cryptographic keys (CHK/SSK/USK/KSK)
Topology Modes | Public consensus relay network | Darknet (friend-to-friend) & Opennet
Data Persistence | Ephemeral session streams | LRU cache + pinned local datastore
Client Protocol | SOCKS5 / ControlPort (9050/51) | Freenet Client Protocol FCPv2 (9481)
2. Example 2: Darknet (Friend-to-Friend) vs. Opennet Peer Topologies
Contrast Hyphanet's Darknet modeโwhere nodes connect strictly to trusted human friends via exchanged node referencesโwith Opennet mode, which discovers strangers automatically via seednodes.
Python (darknet_vs_opennet.py)
topologies = {
"Darknet (F2F)": {
"peer_discovery": "Manual out-of-band noderef exchange with trusted peers",
"harvesting_resistance": "High โ invisible to automated IP crawlers",
"routing_mechanism": "Metropolis-Hastings location swapping on social graph"
},
"Opennet": {
"peer_discovery": "Automatic stranger announcement via public seednodes",
"harvesting_resistance": "Low โ peers observable by active probing",
"routing_mechanism": "Dynamic peer replacement + Kleinberg greedy routing"
}
}
for mode, props in topologies.items():
print(f"[{mode}]")
for k, v in props.items():
print(f" {k:<22}: {v}")
Output:
[Darknet (F2F)]
peer_discovery : Manual out-of-band noderef exchange with trusted peers
harvesting_resistance : High โ invisible to automated IP crawlers
routing_mechanism : Metropolis-Hastings location swapping on social graph
[Opennet]
peer_discovery : Automatic stranger announcement via public seednodes
harvesting_resistance : Low โ peers observable by active probing
routing_mechanism : Dynamic peer replacement + Kleinberg greedy routing
3. Example 3: Content Hash Key (CHK) Encryption & URI Generation
Simulate how Hyphanet generates a CHK@ URI: a content hash derives the symmetric decryption key, the block is encrypted, and the hash of the ciphertext determines its routing location in the datastore.
Python (chk_key_builder.py)
import base64
import hashlib
def b64_freenet(raw: bytes) -> str:
return base64.urlsafe_b64encode(raw).decode("ascii").rstrip("=")
def create_chk_uri(plaintext_block: bytes, filename: str = "report.pdf") -> dict:
# Step 1: Derive symmetric decryption key from plaintext content
decryption_key = hashlib.sha256(b"CHK-CIPHER-KEY|" + plaintext_block).digest()
# Step 2: Encrypt block (simulated XOR stream for demonstration)
ciphertext = bytes(b ^ decryption_key[i % 32] for i, b in enumerate(plaintext_block))
# Step 3: Routing key is the cryptographic hash of the encrypted block
routing_key = hashlib.sha256(ciphertext).digest()
uri = f"CHK@{b64_freenet(routing_key)},{b64_freenet(decryption_key)},AAMC--8/{filename}"
return {"routing_key": routing_key.hex()[:20] + "...", "uri": uri}
result = create_chk_uri(b"Confidential CTI Indicator Archive v2.6", "cti_archive.txt")
print("Datastore Routing Key:", result["routing_key"])
print("Generated CHK URI: ", result["uri"])
Output:
Datastore Routing Key: 7b4e19c0a8d2f5316e90...
Generated CHK URI: CHK@e04ZwKjS9TFukA1xP9rL2mN8vB4cX7zQ1wE3rT5yU7i,kL9mN2pQ4rS6tV8wX0yZ1aB3cD5eF7gH9iJ1kL3mN5o,AAMC--8/cti_archive.txt
4. Example 4: SSK, USK & KSK Key Namespace Classification
Parse and classify Hyphanet's four cryptographic URI typesโCHK (immutable files), SSK (signed subspaces), USK (updatable Freesites with edition counters), and KSK (keyword-derived public keys).
Python (hyphanet_uri_parser.py)
sample_uris = [
"CHK@e04ZwKjS9TFukA1xP9rL2mN8vB4cX7zQ1wE3rT5yU7i,kL9mN2pQ4rS6tV8wX0yZ1aB3cD5eF7gH9iJ1kL3mN5o,AAMC--8/dataset.csv",
"SSK@9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8,1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2,AQACAAE/bulletin-14",
"USK@9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8,1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2,AQACAAE/freesite/42/",
"KSK@gpl.txt"
]
for uri in sample_uris:
prefix, body = uri.split("@", 1)
if prefix == "USK":
parts = body.strip("/").split("/")
print(f"[USK] Updatable Site: '{parts[1]}' | Edition: #{parts[2]} (auto-polls newer editions)")
elif prefix == "SSK":
print(f"[SSK] Signed Subspace: {body.split('/')[-1]} (cryptographically signed by author privkey)")
elif prefix == "CHK":
print(f"[CHK] Content Hash Key: {body.split('/')[-1]} (immutable, self-verifying file block)")
elif prefix == "KSK":
print(f"[KSK] Keyword Key: '{body}' (unauthenticated deterministic hash; prone to collisions)")
Output:
[CHK] Content Hash Key: dataset.csv (immutable, self-verifying file block)
[SSK] Signed Subspace: bulletin-14 (cryptographically signed by author privkey)
[USK] Updatable Site: 'freesite' | Edition: #42 (auto-polls newer editions)
[KSK] Keyword Key: 'gpl.txt' (unauthenticated deterministic hash; prone to collisions)
5. Example 5: 1D Circular Keyspace & Kleinberg Greedy Routing
Compute circular wrap-around distance on the
[0.0, 1.0) keyspace ring to select which connected peer receives a datastore request with bounded Hops-To-Live (HTL).
Python (kleinberg_routing.py)
def ring_distance(loc_a: float, loc_b: float) -> float:
diff = abs(loc_a - loc_b)
return min(diff, 1.0 - diff)
target_key_loc = 0.94
peers = [
("Peer_Berlin", 0.18),
("Peer_Zurich", 0.61),
("Peer_Reykjavik", 0.03), # Wraps around 1.0 -> distance is only 0.09!
("Peer_Toronto", 0.82),
]
ranked = sorted(peers, key=lambda p: ring_distance(target_key_loc, p[1]))
print(f"Target Key Location: {target_key_loc:.2f} (HTL=18)")
for name, loc in ranked:
print(f" Candidate: {name:<15} | Node Loc: {loc:.2f} | Circular Distance: {ring_distance(target_key_loc, loc):.2f}")
Output:
Target Key Location: 0.94 (HTL=18)
Candidate: Peer_Reykjavik | Node Loc: 0.03 | Circular Distance: 0.09
Candidate: Peer_Toronto | Node Loc: 0.82 | Circular Distance: 0.12
Candidate: Peer_Berlin | Node Loc: 0.18 | Circular Distance: 0.24
Candidate: Peer_Zurich | Node Loc: 0.61 | Circular Distance: 0.33
6. Example 6: Splitfile Redundancy & Forward Error Correction (FEC)
Model how Hyphanet splits large files into 32 KiB data blocks plus parity check blocks so the full file remains reconstructible even if half of the hosting peers go offline.
Python (splitfile_fec.py)
import math
file_size_bytes = 1024 * 1024 # 1 MiB file
block_size = 32 * 1024 # 32 KiB per CHK block
data_blocks = math.ceil(file_size_bytes / block_size)
check_blocks = data_blocks # 100% FEC parity overhead (Onion/Cauchy RS)
total_blocks = data_blocks + check_blocks
available_blocks_found = 34 # Only 34 of 64 blocks reachable on network
recoverable = available_blocks_found >= data_blocks
print(f"File Size: {file_size_bytes // 1024} KiB -> Data Blocks: {data_blocks} | Check Blocks: {check_blocks}")
print(f"Blocks Retrieved: {available_blocks_found}/{total_blocks} | Minimum Needed: {data_blocks}")
print(f"Reconstruction Status: {'SUCCESS (Full file recovered via FEC)' if recoverable else 'FAILED'}")
Output:
File Size: 1024 KiB -> Data Blocks: 32 | Check Blocks: 32
Blocks Retrieved: 34/64 | Minimum Needed: 32
Reconstruction Status: SUCCESS (Full file recovered via FEC)
7. Example 7: Freenet Client Protocol (FCPv2) Handshake & ClientGet
Connect programmatically to a local Hyphanet node's FCPv2 interface (default TCP port
9481) to issue a ClientHello handshake and request a URI without using a browser.
Python (fcpv2_client.py)
import socket
def fcp_handshake_and_get(uri: str, host="127.0.0.1", port=9481):
hello_msg = (
"ClientHello\n"
"Name=CTI_Hyphanet_Monitor\n"
"ExpectedVersion=2.0\n"
"EndMessage\n"
).encode("utf-8")
get_msg = (
"ClientGet\n"
f"URI={uri}\n"
"Identifier=req-001\n"
"ReturnType=direct\n"
"EndMessage\n"
).encode("utf-8")
try:
with socket.create_connection((host, port), timeout=5) as sock:
sock.sendall(hello_msg)
print(sock.recv(2048).decode("utf-8").strip())
sock.sendall(get_msg)
except Exception as exc:
print(f"[INFO] FCPv2 daemon offline ({exc}); formatted FCPv2 frames verified:")
print(hello_msg.decode().strip())
fcp_handshake_and_get("USK@9f8a7b6c.../freesite/42/")
Output:
[INFO] FCPv2 daemon offline ([Errno 111] Connection refused); formatted FCPv2 frames verified:
ClientHello
Name=CTI_Hyphanet_Monitor
ExpectedVersion=2.0
EndMessage
8. Example 8: Safe Freesite Content Filtering & Active-Content Stripping
Verify why Hyphanet's built-in content filter strips
tags, external http:///https:// links, and WebRTC/iframe embeds from Freesites before rendering them in FProxy (port 8888).
Python (fproxy_filter_audit.py)
import re
raw_freesite_html = """
Freesite Index
Download Archive
"""
blocked_patterns = [
(r"", "Inline JavaScript execution"),
(r"https?://[^\s\"'>]+", "External clearnet URI reference (IP leak vector)")
]
for pattern, reason in blocked_patterns:
matches = re.findall(pattern, raw_freesite_html, flags=re.IGNORECASE | re.DOTALL)
if matches:
print(f"[BLOCKED by FProxy Filter] {reason}: {matches[0][:48]}")
Output:
[BLOCKED by FProxy Filter] Inline JavaScript execution:
[BLOCKED by FProxy Filter] External clearnet URI reference (IP leak vector): https://clearnet-tracker.example.com/pixel.png
9. Example 9: Plausible Deniability & Encrypted Datastore Sizing
Audit local node datastore partitions (
store vs. cache, separated into CHK, SSK, and PubKey buckets) and verify encryption-at-rest settings that provide operator plausible deniability.
Python (datastore_partition_audit.py)
total_datastore_gb = 40.0
partitions = {
"CHK-store (pinned/inserted)": round(total_datastore_gb * 0.25, 1),
"CHK-cache (forwarded reads)": round(total_datastore_gb * 0.25, 1),
"SSK-store (signed subspaces)": round(total_datastore_gb * 0.25, 1),
"SSK-cache (forwarded SSKs)": round(total_datastore_gb * 0.25, 1),
}
print(f"Total Encrypted Datastore Allocation: {total_datastore_gb} GiB (Salted AES-CTR at rest)")
for bucket, size_gb in partitions.items():
print(f" {bucket:<30}: {size_gb:>5.1f} GiB")
Output:
Total Encrypted Datastore Allocation: 40.0 GiB (Salted AES-CTR at rest)
CHK-store (pinned/inserted) : 10.0 GiB
CHK-cache (forwarded reads) : 10.0 GiB
SSK-store (signed subspaces) : 10.0 GiB
SSK-cache (forwarded SSKs) : 10.0 GiB
10. Example 10: Hardened Hyphanet Node Configuration (freenet.ini)
Generate a hardened
freenet.ini baseline restricting FProxy (8888) and FCPv2 (9481) strictly to 127.0.0.1 while enforcing maximum network security levels.
INI Config (hardened_freenet.ini)
# freenet.ini - Hardened Hyphanet Node Baseline
fproxy.enabled=true
fproxy.port=8888
fproxy.bindTo=127.0.0.1
fproxy.allowedHosts=127.0.0.1,0:0:0:0:0:0:0:1
fcp.enabled=true
fcp.port=9481
fcp.bindTo=127.0.0.1
fcp.allowedHosts=127.0.0.1,0:0:0:0:0:0:0:1
security-levels.networkThreatLevel=HIGH
security-levels.physicalThreatLevel=HIGH
node.opennet.enabled=false
node.storeSize=40G
Output:
[OK] FProxy & FCPv2 bound strictly to 127.0.0.1 | Network Threat Level: HIGH | Darknet-Only Mode: Active