mirror of
https://github.com/logos-blockchain/research.git
synced 2026-08-07 11:43:20 +00:00
Static-graph simulator quantifying how a node's peering degree trades off propagation speed, adversary exposure, deanonymization, and reliability in the Blend network. Scales to 1e6 nodes (sparse CSR + sampled Dijkstra); the adversary and deanonymization metrics are exact at every N. Model (ms): seeded d-regular peer graph (matching-union), Blend cascade (sender -> blend_hops timed-release mix relays -> final flood), geographic link base + exponential transport jitter, per-node processing lag, free-running release-clock mixing. Metrics: - propagation: full-delay mean/p50/p90/p99, path/broadcast split, coverage times - reliability: message success-delivery-rate ~ (1-unresponsive_frac)^blend_hops and flood coverage, with unresponsive nodes modelled as routing holes - adversary (exact): observed/eclipsed fractions, random + worst-case placement - deanonymization (exact): P(whole blend path adversarial) ~ f_adv^blend_hops, and full deanonymization (path adversarial AND honest sender peered with an adversary) = deanon_rate * observed_frac Deterministic blake2b seed streams, three parquet tables, joblib parallelism, memguard, an analytic verify harness, 50 unit tests, and an auto-installing Makefile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
from pd.config import SimConfig
|
|
from pd.rng import (
|
|
graph_seedseq,
|
|
responsive_seedseq,
|
|
rng_for,
|
|
round_seedseq,
|
|
seedseq_for,
|
|
)
|
|
|
|
|
|
def test_deterministic():
|
|
c = SimConfig(n_nodes=1000, degree=8, graph_seed=3)
|
|
assert seedseq_for(c).entropy == seedseq_for(c).entropy
|
|
a = rng_for(c).integers(0, 10**9, size=5)
|
|
b = rng_for(c).integers(0, 10**9, size=5)
|
|
assert list(a) == list(b)
|
|
|
|
|
|
def test_graph_seed_is_topology_only():
|
|
base = SimConfig(n_nodes=1000, degree=8, graph_seed=3, f_adv=0.0, blend_hops=2)
|
|
same_topo = SimConfig(n_nodes=1000, degree=8, graph_seed=3, f_adv=0.4, blend_hops=5,
|
|
adversary_mode="worstcase_coverage", n_rounds=999)
|
|
assert graph_seedseq(base).entropy == graph_seedseq(same_topo).entropy
|
|
diff_topo = SimConfig(n_nodes=1000, degree=8, graph_seed=4)
|
|
assert graph_seedseq(base).entropy != graph_seedseq(diff_topo).entropy
|
|
|
|
|
|
def test_responsive_seed_depends_on_frac_only():
|
|
c = SimConfig(n_nodes=1000, degree=8, graph_seed=3)
|
|
# fixed per (topology, unresponsive_frac); different frac -> different responsive draw
|
|
assert responsive_seedseq(c, 0.1).entropy == responsive_seedseq(c, 0.1).entropy
|
|
assert responsive_seedseq(c, 0.1).entropy != responsive_seedseq(c, 0.2).entropy
|
|
|
|
|
|
def test_round_seed_includes_unresponsive_frac():
|
|
c = SimConfig(n_nodes=1000, degree=8, graph_seed=3)
|
|
a = round_seedseq(c, blend_hops=3, max_blend_delay=3, unresponsive_frac=0.0)
|
|
b = round_seedseq(c, blend_hops=3, max_blend_delay=3, unresponsive_frac=0.2)
|
|
assert a.entropy != b.entropy
|