diff --git a/code/check_cov_attack.py b/code/check_cov_attack.py index accd361..6a53278 100644 --- a/code/check_cov_attack.py +++ b/code/check_cov_attack.py @@ -18,16 +18,18 @@ Procedure, using nothing the threat model keeps secret: 6. report the recovered-entry fraction and the eavesdropper SER, both WITHOUT ever using a known index -Run under WSL. Prints a verdict; writes nothing to data/. +Run under WSL. Writes data/cov_attack.csv so the manuscript sentence +it supports is traceable to a stored artifact. """ from __future__ import annotations import itertools import math +from pathlib import Path import numpy as np import torch from sse_lib import rayleigh_gain, DEVICE -from exp_full import get_model, hadamard, eval_ser_eve +from exp_full import main_model, hadamard, eval_ser_eve def collect_frames(m, n, snr_db, seed): @@ -94,18 +96,25 @@ def attack(m, snr_db, n_frames, seed): def main(): - U, L = 4, 16 - K0 = torch.tensor(hadamard(L)[1:U + 1], dtype=torch.float32) - m = get_model(iters=4000, freeze_W=K0) + import csv + m = main_model() m.eval() chance = 1.0 - (1.0 / m.vu) ** m.P - print(f"chance SER = {chance:.5f}, legitimate reference ~0.276") + print(f"chance SER = {chance:.5f} at the main configuration") print("ciphertext-only (NO known plaintext):") + rows = [] for snr in (10.0, 20.0): for nf in (300, 1000, 10000): frac, ser = attack(m, snr, nf, seed=1234 + nf) + rows.append((snr, nf, "%.4f" % frac, "%.4f" % ser)) print(f" {snr:4.0f} dB N={nf:6d} " f"key-entry recovery={frac:.3f} eve SER={ser:.4f}") + out = Path(__file__).resolve().parents[1] / "data" / "cov_attack.csv" + with open(out, "w", newline="") as f: + w = csv.writer(f) + w.writerow(["snr_db", "n_frames", "entry_recovery", "eve_ser"]) + w.writerows(rows) + print("[csv]", out) if __name__ == "__main__": diff --git a/code/replot_security.py b/code/replot_security.py index 0977790..4d837a7 100644 --- a/code/replot_security.py +++ b/code/replot_security.py @@ -34,10 +34,10 @@ FIG.mkdir(exist_ok=True) plt.rcParams.update({ "font.family": "serif", "font.serif": ["DejaVu Serif", "Times New Roman"], - # The manuscript includes each result figure at 0.70 of a 3.455 in - # column while the canvas is 3.15 in, a printed scale of 0.768. Every + # The manuscript includes each result figure at 0.62 of a 3.455 in + # column while the canvas is 3.15 in, a printed scale of 0.680. Every # size below is therefore pre-divided by that scale so the PRINTED - # sizes are 9 pt labels, 8 pt ticks and a 6.6 pt legend. Change the + # sizes are 8 pt labels, 7 pt ticks and a 5.5 pt legend. Change the # include width and these must change with it. "font.size": 10.4, "axes.labelsize": 10.4, @@ -50,7 +50,7 @@ plt.rcParams.update({ "grid.alpha": 0.6, "lines.linewidth": 1.5, "lines.markersize": 5.2, - "figure.figsize": (3.15, 2.36), + "figure.figsize": (3.15, 2.25), # shorter canvas: same printed width and font size, less page height "pdf.fonttype": 42, }) AXES_RECT = dict(left=0.205, right=0.970, top=0.955, bottom=0.215) @@ -283,7 +283,7 @@ def fig_snr(): ax.set_xlim(min(x), max(x)) # most of a decade below the data leaves the lower-left genuinely # empty, which is what gives the four-entry legend a clear berth - ax.set_ylim(bottom=8e-4) + ax.set_ylim(bottom=2e-4) place_legend(ax) save(fig, "fig_sec_snr") diff --git a/data/cov_attack.csv b/data/cov_attack.csv new file mode 100644 index 0000000..88a6ca1 --- /dev/null +++ b/data/cov_attack.csv @@ -0,0 +1,7 @@ +snr_db,n_frames,entry_recovery,eve_ser +10.0,300,0.9023,0.2583 +10.0,1000,0.8047,0.6036 +10.0,10000,0.8477,0.4613 +20.0,300,0.7852,0.6494 +20.0,1000,0.7734,0.7093 +20.0,10000,0.8164,0.4676 diff --git a/fig/fig_sec_brute.pdf b/fig/fig_sec_brute.pdf index 78c4210..45ff581 100644 Binary files a/fig/fig_sec_brute.pdf and b/fig/fig_sec_brute.pdf differ diff --git a/fig/fig_sec_jam.pdf b/fig/fig_sec_jam.pdf index ed3bd49..bc66afd 100644 Binary files a/fig/fig_sec_jam.pdf and b/fig/fig_sec_jam.pdf differ diff --git a/fig/fig_sec_keylen.pdf b/fig/fig_sec_keylen.pdf index 0a17c53..f1c9962 100644 Binary files a/fig/fig_sec_keylen.pdf and b/fig/fig_sec_keylen.pdf differ diff --git a/fig/fig_sec_kpa.pdf b/fig/fig_sec_kpa.pdf index 33783e6..3c90169 100644 Binary files a/fig/fig_sec_kpa.pdf and b/fig/fig_sec_kpa.pdf differ diff --git a/fig/fig_sec_real.pdf b/fig/fig_sec_real.pdf index bdd9335..b9daf2f 100644 Binary files a/fig/fig_sec_real.pdf and b/fig/fig_sec_real.pdf differ diff --git a/fig/fig_sec_sens.pdf b/fig/fig_sec_sens.pdf index f210c58..d2fb5a0 100644 Binary files a/fig/fig_sec_sens.pdf and b/fig/fig_sec_sens.pdf differ diff --git a/fig/fig_sec_snr.pdf b/fig/fig_sec_snr.pdf index f6c5ef9..fc6b341 100644 Binary files a/fig/fig_sec_snr.pdf and b/fig/fig_sec_snr.pdf differ