Ciphertext-only family enumeration, and checks that reproduce off a GPU
check_family_enum.py measures the attack the manuscript now states in Section III-A: the winning correlation is an index-free verifier, so ranking the 63 non-constant Walsh rows by mean winning correlation recovers the user set from one frame in 0.905 of 200 trials at 10 dB and from four frames in 0.990, using nothing outside the stated threat model. Under the invariance refresh it recovers it in none, because the entry permutation relabels the codebook the adversary must align against. V8 and V9 read the trained codebook through main_model(), which retrains on every call, and a codebook trained on CUDA is not the one trained on CPU. The shipped verify_math.csv therefore read PASS here and FAIL for anyone running this package without a GPU. model_main.pt is 7 KB and fixes the codebook, which is what both checks are about; delete it to retrain. V1-V11 now pass on both. New checks: V10, the format-matched OMA reference Section VI-B quotes, and V11, the closed-form against Monte Carlo comparison the manuscript claimed and never stored. V3a's bias-linearity result was computed and printed but never written to the CSV, so the one linearity claim the paper quotes was the one this package could not show. check_consistency.py gains 21 assertions, covering five data files that no assertion read (users, csi, semantic, cov_attack, sec_jam) and the trend claims it structurally could not see, since it compared values and not shapes. README: the figure map named stages that do not write the artifacts they list, so following it did not reproduce Figs. 4 and 6; the reproduction block was five scripts short; and the refresh numbers were from a superseded run (nearly three, 15.0 to 64.8 bits) against the manuscript's 2.3 and 23.8 to 364.6.
This commit is contained in:
+65
-4
@@ -18,9 +18,32 @@ Run on CPU (NumPy); no training involved, pure algebra checks.
|
||||
from __future__ import annotations
|
||||
import numpy as np
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
RNG = np.random.default_rng(2026)
|
||||
D, U, V = 64, 4, 256
|
||||
|
||||
CKPT = Path(__file__).resolve().parent.parent / "data" / "model_main.pt"
|
||||
|
||||
|
||||
def cached_main_model():
|
||||
"""The trained main-configuration model, from a checkpoint.
|
||||
|
||||
V8 and V9 read the trained codebook. Retraining it reproduces only
|
||||
on the device that trained it, so a CPU run of the released package
|
||||
disagreed with the shipped numbers. The checkpoint fixes the
|
||||
codebook, which is what both checks are about; delete it to retrain.
|
||||
"""
|
||||
import torch
|
||||
from exp_full import main_model
|
||||
m = main_model()
|
||||
if CKPT.exists():
|
||||
m.load_state_dict(torch.load(CKPT, map_location="cpu"))
|
||||
else:
|
||||
torch.save({k: v.cpu() for k, v in m.state_dict().items()}, CKPT)
|
||||
return m
|
||||
|
||||
|
||||
|
||||
def unit_codebook(V, d, rng):
|
||||
E = rng.standard_normal((V, d))
|
||||
@@ -121,6 +144,9 @@ def v3_leakage_vs_correlation():
|
||||
lin_ok = all(abs(b - rho * b1) <= 3e-2 for rho, b in slopes)
|
||||
print(f"[{'PASS' if lin_ok else 'FAIL'}] V3a bias linear in rho: "
|
||||
+ ", ".join(f"rho={r:.2f}->{b:.3f}" for r, b in slopes))
|
||||
ROWS.append(("V3a bias slope in kappa", "1.0", "%.4f" % b1,
|
||||
"%.4f" % abs(1.0 - b1), "0.03",
|
||||
"PASS" if lin_ok else "FAIL"))
|
||||
# (b) random independent mask correlation: E|corr| = sqrt(2/(pi d))
|
||||
# (the folded-normal mean of a N(0, 1/d) variable)
|
||||
corrs = []
|
||||
@@ -263,8 +289,7 @@ def v8_cross_period_terms():
|
||||
the codebook, which is the claim the proof rests on."""
|
||||
import math
|
||||
import torch
|
||||
from exp_full import main_model
|
||||
m = main_model()
|
||||
m = cached_main_model()
|
||||
Bn = m.unit_codebook().detach().cpu()
|
||||
pat = m.masks().detach().cpu()[0]
|
||||
L, P, d = m.L, m.P, m.d
|
||||
@@ -294,8 +319,7 @@ def v9_score_variance_ratio():
|
||||
of sum_j e_j^4 / sum_j e_j^2 e'_j^2 over ordered codeword pairs of
|
||||
the trained unit codebook, quoted as 2.8 in the manuscript."""
|
||||
import torch
|
||||
from exp_full import main_model
|
||||
m = main_model()
|
||||
m = cached_main_model()
|
||||
B = m.unit_codebook().detach().cpu().double()
|
||||
B = B / B.norm(dim=1, keepdim=True)
|
||||
n = B.shape[0]
|
||||
@@ -313,6 +337,41 @@ def v9_score_variance_ratio():
|
||||
return ok
|
||||
|
||||
|
||||
|
||||
def v10_format_matched_oma():
|
||||
"""The format-matched OMA reference of Section VI-B.
|
||||
|
||||
The binary reference spends 16 of its 64 exclusive dimensions on
|
||||
antipodal bits. The same allocation spent the way the proposed
|
||||
scheme spends it, P=4 sixteen-ary orthogonal decisions over 16
|
||||
dimensions each, is the comparison a reviewer will ask for."""
|
||||
from sse_lib import oma_ser_orth
|
||||
from exp_full import oma_ser_keylen
|
||||
val = oma_ser_orth([10.0])[0]
|
||||
binary = oma_ser_keylen(64, 10.0)
|
||||
ok = abs(val - 0.055) < 0.001
|
||||
print("V10 format-matched OMA at 10 dB: %.5f (binary %.5f)"
|
||||
% (val, binary))
|
||||
ROWS.append(("V10 format-matched OMA at 10 dB", "0.055", "%.5f" % val,
|
||||
"%.5f" % abs(val - 0.055), "0.001", "PASS" if ok else "FAIL"))
|
||||
return ok
|
||||
|
||||
|
||||
def v11_oma_closed_form_vs_mc():
|
||||
"""The manuscript says the OMA closed form agrees with Monte Carlo
|
||||
to within one percent. That check had no stored artifact."""
|
||||
from sse_lib import oma_ser, oma_ser_mc
|
||||
cf = oma_ser([16.0])[0]
|
||||
mc = oma_ser_mc([16.0], frames=2_000_000)[0]
|
||||
rel = abs(cf - mc) / mc
|
||||
ok = rel < 0.01
|
||||
print("V11 OMA closed form %.6f vs Monte Carlo %.6f (%.2f%%)"
|
||||
% (cf, mc, 100 * rel))
|
||||
ROWS.append(("V11 OMA closed form vs Monte Carlo", "%.6f" % mc,
|
||||
"%.6f" % cf, "%.4f" % rel, "0.01", "PASS" if ok else "FAIL"))
|
||||
return ok
|
||||
|
||||
|
||||
def main():
|
||||
print(f"config d={D} U={U} V={V}\n")
|
||||
results = {
|
||||
@@ -325,6 +384,8 @@ def main():
|
||||
"V7": v7_symbolic_identities(),
|
||||
"V8": v8_cross_period_terms(),
|
||||
"V9": v9_score_variance_ratio(),
|
||||
"V10": v10_format_matched_oma(),
|
||||
"V11": v11_oma_closed_form_vs_mc(),
|
||||
}
|
||||
print("\nsummary:", {k: ("PASS" if v else "FAIL") for k, v in results.items()})
|
||||
print("ALL PASS" if all(results.values()) else "SOME FAILED")
|
||||
|
||||
Reference in New Issue
Block a user