Files
TOIFAS/code/make_tables.py
T
KiHoLee 17d23fa76a 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.
2026-08-28 17:40:28 +09:00

108 lines
3.9 KiB
Python

"""Generate the LaTeX rows of every result table from the CSVs, so
that every table in the paper is reproducible from data/ (TIFS mandate).
Prints the tabular bodies; paste into main.tex without edits.
"""
from __future__ import annotations
import csv
import json
import math
from pathlib import Path
DATA = Path(__file__).resolve().parents[1] / "data"
NAME = {
"proposed": r"\textbf{Proposed keyed masking}",
"public_mask": "Public masks",
"perm_key": r"Permutation key~\cite{chen2025shufflingtifs}",
"index_cipher": "Index cipher",
"oma_plain": "OMA (no encryption)",
"random": "Random",
"hadamard": "Walsh-Hadamard",
"learned": "Learned",
"learned_reg": r"Regularized~\eqref{eq:regloss}",
}
RECEIVER = {
"legit": "Legitimate", "oma": "OMA",
"insider": "Insider", "eve": "Outsider",
}
def f3(x: str) -> str:
"""Three decimals, or an em-dash for a value that does not apply."""
try:
v = float(x)
except (TypeError, ValueError):
return "--"
return "--" if math.isnan(v) else f"{v:.3f}"
def f4(x: str) -> str:
"""Four decimals, for a column whose values sit against the
random-guess level and would otherwise all print as 1.000 while the
body quotes their distance from it in units of 1e-4."""
try:
v = float(x)
except (TypeError, ValueError):
return "--"
return "--" if math.isnan(v) else f"{v:.4f}"
def cell(x: str, bold: bool, wide: bool = False) -> str:
s = f4(x) if wide else f3(x)
if s == "--":
return "--"
return rf"$\mathbf{{{s}}}$" if bold else f"${s}$"
def compare_table():
print("% Table: scheme comparison (from sec_compare.csv)")
rows = list(csv.DictReader(open(DATA / "sec_compare.csv")))
order = ["public_mask", "perm_key", "index_cipher", "oma_plain", "proposed"]
rows.sort(key=lambda r: order.index(r["scheme"]))
# stage_E does not jam the orthogonal reference, because the jammer an
# OMA user faces is targeted at public slots rather than mask-matched
# or mask-blind. stage_L measures that case, so the cell comes from
# there instead of being left empty.
jam = {float(r["jsr_db"]): r
for r in csv.DictReader(open(DATA / "sec_jam_cmp.csv"))}
oma_jam = jam[0.0]["oma_targeted"]
for r in rows:
b = r["scheme"] == "proposed"
if r["scheme"] == "oma_plain" and f3(r["jam0_ser"]) == "--":
r["jam0_ser"] = oma_jam
# four decimals would still print 1.0000 here, so the column
# stays at three and the caption names the chance level
cells = [cell(r[k], b) for k in
("legit_ser", "eve_out", "eve_in", "jam0_ser")]
print(f"{NAME[r['scheme']]} & " + " & ".join(cells) + r" \\")
def maskfam_table():
print("% Table: key families (from sec_maskfam.csv)")
for r in csv.DictReader(open(DATA / "sec_maskfam.csv")):
# the structured family is the main configuration, so its row is
# emphasized the same way the proposed row is in the comparison
b = r["family"] == "hadamard"
cells = [cell(r[k], b) for k in
("legit_ser", "eve_ser", "eve_ones_ser", "mask_xcorr")]
name = NAME[r["family"]]
if b:
name = r"\textbf{" + name + "}"
print(f"{name} & " + " & ".join(cells) + r" \\")
def refresh_tables():
print("% Table: key refresh (from refresh_summary.csv)")
for r in csv.DictReader(open(DATA / "refresh_summary.csv")):
b = r["scheme"] == "Invariant"
name = r"\textbf{Invariant}" if b else r["scheme"]
f = (lambda t: r"\mathbf{" + t + "}") if b else (lambda t: t)
print(f"{name} & ${f(format(float(r['legit']), '.3f'))}$ & "
f"${f(format(float(r['eve']), '.4f'))}$ & "
# the unit lives in the header, not in every cell
f"${f(format(float(r['entropy_bits']), '.1f'))}$" + r" \\")
if __name__ == "__main__":
compare_table(); print()
maskfam_table(); print()
refresh_tables()