Marcin Pawlowski 6ad63ce2f3
Add pd: peering-degree Blend Monte-Carlo graph simulator
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>
2026-08-06 17:59:55 +02:00

46 lines
1.2 KiB
Makefile

VENV ?= .venv
PY := $(VENV)/bin/python
STAMP := $(VENV)/.installed
# Keep numpy/scipy BLAS single-threaded so joblib process parallelism doesn't oversubscribe.
export OMP_NUM_THREADS := 1
export OPENBLAS_NUM_THREADS := 1
export MKL_NUM_THREADS := 1
export NUMEXPR_NUM_THREADS := 1
.PHONY: install smoke sweep sweep-fullscale figures verify test lint clean
# The stamp is the real install; targets below depend on it so `make sweep` (etc.) auto-installs
# on a fresh checkout and re-installs whenever pyproject.toml changes.
$(STAMP): pyproject.toml
python3 -m venv $(VENV)
$(PY) -m pip install -U pip
$(PY) -m pip install -e ".[dev]"
@touch $(STAMP)
install: $(STAMP)
smoke: $(STAMP) ## fast end-to-end (seconds): tiny N, few rounds/seeds
$(PY) -m pd.sweep --config configs/smoke.yaml
sweep: $(STAMP)
$(PY) -m pd.sweep --config configs/default.yaml
sweep-fullscale: $(STAMP)
$(PY) -m pd.sweep --config configs/fullscale.yaml
figures: $(STAMP) ## make figures RUN=runs/<dir>
$(PY) -m pd.plotting.make_figures --run $(RUN)
verify: $(STAMP)
$(PY) -m pd.verify
test: $(STAMP)
$(PY) -m pytest
lint: $(STAMP)
$(VENV)/bin/ruff check src scripts tests
clean:
rm -rf runs/* figures/* .pytest_cache .ruff_cache .mypy_cache