Jittered side-channel trace hypothesis scan
/app/cpu/main.cpp is a multicore CPU program (C++17, OpenMP). It is built as
/app/bin/cpu_baseline with g++ -O3 -march=native -fopenmp -std=c++17 and run as
cpu_baseline INPUT_FILE
It reads one input file and writes its result to stdout.
What the program computes
A side-channel analyst has many short, noisy measurements of an unknown byte operation. The program generates G independent campaigns, corrects a drifting baseline in each trace, scores all 256 byte hypotheses at every sample, and reports the strongest peaks plus a checksum of the full score surface. Each campaign contains N traces of T signed samples. Public parameters and a 64-bit seed generate the bulk data deterministically inside the program.
For trace i, plaintext p_i is generated by mix64(seed ^ campaign_tag ^ i_tag) & 255. The campaign's hidden byte is also generated from the seed. A hypothesis h predicts the centered leakage popcount(F(p_i xor h)) - 4, where F(x) = rotl8((77x+29) mod 256,3) xor (13x+5) mod 256. Measurements contain deterministic hash noise, a per-trace offset, a jittered pulse from the hidden byte and a weaker distractor pulse from a second byte. The offset estimate is the integer mean of the first four samples; it is subtracted from every sample.
For each (h,t) with t >= 4, the exact integer score is the absolute centered cross-moment |N sum_i(l_i y_it) - (sum_i l_i)(sum_i y_it)|. The program ranks all pairs by descending score, then smaller hypothesis and earlier sample, and emits the top three plus a mixed checksum over every pair's score. The checksum makes the full scan part of the answer even when the top peak is obvious.
The task tests reuse across a hypothesis-by-time-by-trace computation, irregular leakage values, exact reductions, baseline correction and deterministic ranking. It is distinct from block-cipher avalanche testing, which measures differences between chosen plaintext/ciphertext pairs rather than inferring leakage from noisy traces.
Input format
One line: G N T SEED. 1 <= G <= 64, 1 <= N <= 65536, 4 <= T <= 256, SEED is an unsigned 64-bit decimal integer.
Output format
One line per campaign:
batch B hash=HHHHHHHHHHHHHHHH top=H:T:S,H:T:S,H:T:S
The hash is 16 lowercase hexadecimal digits. When T=4, no score pairs exist and top=none. All scores are unsigned decimal integers. Candidate pairs are unique. This is exact-output grading.
Hidden inputs
Correctness inputs cover N=1, non-power-of-two trace counts, T=4, multiple campaigns, and varied seeds. The timing case is G=64, N=65536, T=256 at scale 1.0. Only the number of independent campaigns scales for smaller timing inputs. CPU and CUDA must reproduce the same 64-bit hash arithmetic, signed integer division truncation, and ranking tie-breaks.
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The CPU source is the specification: when this text and the code disagree, the code wins.
How you are scored
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. Inputs are generated with a new random seed at grading time, so they cannot be known in advance. - Correctness: every hidden input (small edge cases plus the timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- Speed: The scale-1.0 input runs 64 independent campaigns with 65536 traces and 256 samples each; the scan evaluates about 270 billion trace-hypothesis-time contributions. Your port and our GPU reference are each run on it
once to warm up and then 5 times, interleaved; the time is the wall clock of the whole process
(including CUDA initialisation, input parsing and output). When correct,
reward = min(2, t_reference / t_yours)using the medians. /app/inputs/holds a few public inputs./app/bin/run_public.shcompiles your port with the flags above and compares it against the CPU baseline on each of them.