Executables Reference
All executables are built with dune build from inside alvie/code/ and run as:
_build/default/bin/<name>.exe [flags]from the alvie/code/ directory unless a --tmpdir or --sancus path says otherwise.
1. learn.exe — Learn a Mealy machine model
Section titled “1. learn.exe — Learn a Mealy machine model”Purpose: Runs the L# active automata learning algorithm against a Sancus Verilog simulation.
Produces a .dot file representing the learned Mealy machine: the attacker’s observable behavior of the enclave.
This is the main experiment driver.
Required flags
Section titled “Required flags”| Flag | Description |
|---|---|
--att-spec <file> | Path to attacker specification (.atdl file) |
--encl-spec <file> | Path to enclave specification (.etdl file) |
--oracle <mode> | Query oracle mode: randomwalk, pac, or exhaustive |
--res <file> | Output .dot file path for the learned model |
--tmpdir <dir> | Directory for temporary Verilog simulation files |
--sancus <dir> | Path to the Sancus simulator root |
Other flags
Section titled “Other flags”| Flag | Default | Description |
|---|---|---|
--commit <sha> | ef753b6 | Label or git commit of the Sancus version to check |
--secret <value> | absent | Secret substituted into the enclave specification; required when the spec contains ? |
--epsilon <float> | 0.001 | PAC error bound, used only by pac |
--delta <float> | 0.001 | PAC confidence parameter, used only by pac |
--pac-bound <int> | 1 | Included in --report output only; does not limit the current PAC oracle |
--step-limit <int> | 500 | Max steps for a random-walk equivalence query |
--round-limit <int> | unlimited | Max rounds for a PAC equivalence query |
--reset-probability <float> | 0.05 | Random-walk probability of restarting the current path |
--bad-probability <float> | 0.20 | Probability of generating an input not driven by the specification |
--ignore-interrupts | false | Treat interrupts as invisible (collapse interrupt outputs) |
--keep-repeated-reentries | false | Do not identify a segment of execution between two enclave re-entries with an identical one immediately before it (see Choosing Learner Settings); learning may not finish when an enclave can be resumed repeatedly |
--sancus-master-key <hex> | (default key) | Master key passed to the Sancus simulator |
--dry | false | Dry run: set up the simulator but do not learn |
--report | false | Print a line of learning statistics on stderr (see the log output reference) |
--debug | false | Enable debug-level logging |
--info | false | Enable info-level logging: one line per equivalence-query round and one per counterexample (see the log output reference) |
Environment variables
Section titled “Environment variables”| Variable | Effect |
|---|---|
ALVIE_SIM_CACHE | Directory where compiled simulators are kept and reused (default: simv-cache inside --tmpdir); 0 always compiles. Also used by exec.exe and pbt.exe |
ALVIE_PROFILE | With 1, print on stderr, at the end of the run, the time spent in each part of the learner and of the simulator; SIGUSR1 prints it during the run |
ALVIE_CHECK_APART | With 1, check every answer of the learner’s caches against a computation from scratch, and stop at the first difference. Very slow: for testing changes to the learner |
ALVIE_FULL_TRACE | With 1, the simulator dumps every signal instead of the top level of the testbench (useful to inspect the VCD files); used when the simulator is compiled |
OCAMLRUNPARAM | Garbage collector settings; when it is set, learn.exe does not apply its own |
Output
Section titled “Output”A Mealy machine in .dot format is written to --res.
Each edge is labelled input / output, where inputs and outputs use the symbolic alphabet defined in the specifications.
See the Log and Output Reference for output token meanings.
Quick example
Section titled “Quick example”cd alvie/code_build/default/bin/learn.exe \ --att-spec ../../spec-lib/example/attacker.atdl \ --encl-spec ../../spec-lib/example/enclave.etdl \ --oracle randomwalk \ --secret 0 \ --step-limit 100 \ --res /tmp/example-s0.dot \ --tmpdir /tmp/alvie-example-s0 \ --sancus "$PWD/../../sancus-core-gap" \ --infoThis learns a model for the example attack with secret=0 using random-walk equivalence queries, writing the result to /tmp/example-s0.dot.
Failures and diagnostics
Section titled “Failures and diagnostics”learn.exe, fa.exe, and pbt.exe validate their input files and output directories before running a simulator, model comparison, or property-based test.
learn.exe also validates the oracle, relevant numeric options, Sancus checkout, and secret placeholder before simulator setup.
It exits with status 2 for those user-correctable errors.
An incomplete simulator run exits with status 3 and must not be interpreted as a learned model or security result.
For an unexpected failure, rerun with --debug and file a bug report with the command and sanitized diagnostics.
2. fa.exe — Find flow-analysis (NI) violations between two models
Section titled “2. fa.exe — Find flow-analysis (NI) violations between two models”Purpose: Takes two interrupt-enabled .dot Mealy machines and optionally their two no-interrupt counterparts.
It uses mCRL2 model checking to find distinguishing traces.
Supplying the no-interrupt models removes witnesses that already exist without interrupt scheduling.
| Flag | Default | Description |
|---|---|---|
--m1-int <file> | (required) | secret=0 model, interrupt variant (.dot) |
--m2-int <file> | (required) | secret=1 model, interrupt variant (.dot) |
--m1-nint <file> | optional | secret=0 no-interrupt model (.dot) |
--m2-nint <file> | optional | secret=1 no-interrupt model (.dot) |
--witness-file-basename <base> | (required) | Output path prefix; produces <base>_int.dot |
--tmpdir <dir> | (required) | Directory for intermediate mCRL2 files |
--cex-limit <int> | unlimited | Maximum number of counterexamples to enumerate |
--debug | false | Enable debug-level logging |
Output
Section titled “Output”<witness-file-basename>_int.dot — a .dot graph whose paths are distinguishing traces (attack witnesses).
If no counterexample exists, the file contains one state and no transitions.
The tool prints the number of violations only with --debug.
See Reading and Checking a Witness for how to read the graph.
Quick example
Section titled “Quick example”cd alvie/code_build/default/bin/fa.exe \ --m1-int /tmp/example-orig-s0-int.dot \ --m2-int /tmp/example-orig-s1-int.dot \ --m1-nint /tmp/example-orig-s0-nint.dot \ --m2-nint /tmp/example-orig-s1-nint.dot \ --witness-file-basename /tmp/example-orig-witness \ --tmpdir /tmp/alvie-fa \ --cex-limit 3Produces /tmp/example-orig-witness_int.dot containing up to 3 distinguishing attack traces.
Add --debug to print the number of flow-analysis violations (=== Results: found N FA violations.).
3. exec.exe — Replay an input sequence (debugging tool)
Section titled “3. exec.exe — Replay an input sequence (debugging tool)”Purpose: Developer/debugging utility.
Sets up the Sancus simulator exactly like learn.exe but, instead of learning, replays the input sequence stored in --sexp-input and prints the observed outputs.
It is useful for manually inspecting the simulator’s response to a specific trace without running the full learner.
Same setup flags as learn.exe (minus oracle/learning flags):
| Flag | Description |
|---|---|
--sexp-input <file> | Required S-expression file containing the raw input sequence to replay |
--att-spec <file> | Attacker specification (.atdl) |
--encl-spec <file> | Enclave specification (.etdl) |
--tmpdir <dir> | Temp directory for simulation files |
--sancus <dir> | Path to Sancus simulator root |
--commit <sha> | Simulator git commit to use |
--secret <0|1> | Secret value |
--ignore-interrupts | Collapse interrupt outputs |
--sancus-master-key <hex> | Master key |
--debug | Debug logging |
Output
Section titled “Output”Prints one line per step to stdout: the input sent and the output received from the simulator.
Quick example
Section titled “Quick example”cd alvie/codecat > /tmp/alvie-trace.sexp <<'EOF'((IAttacker(CCreateEncl(enc_s enc_e data_s data_e))) (IAttacker(CJmpIn enc_s)) (IEnclave(CInst I_NOP)))EOF
_build/default/bin/exec.exe \ --sexp-input /tmp/alvie-trace.sexp \ --att-spec ../../spec-lib/example/attacker.atdl \ --encl-spec ../../spec-lib/example/enclave.etdl \ --secret 1 \ --tmpdir /tmp/alvie-exec \ --sancus "$PWD/../../sancus-core-gap" \ --debug4. pbt.exe — Property-based reset-equivalence testing
Section titled “4. pbt.exe — Property-based reset-equivalence testing”Purpose: Uses QCheck to generate two input traces without learning a Mealy machine.
The first trace follows --att-spec1.
The second follows --att-spec2 while reusing the first trace’s enclave actions.
It runs both traces on the selected simulator configuration and checks whether they agree on the occurrence of a reset.
pbt.exe does not substitute secret values or compare the complete attacker-visible output.
It is therefore a focused randomized reset-equivalence smoke test, not a replacement for learn.exe followed by fa.exe.
| Flag | Default | Description |
|---|---|---|
--att-spec1 <file> | (required) | Attacker spec for the first run (.atdl) |
--att-spec2 <file> | (required) | Attacker spec for the second run (.atdl) |
--encl-spec <file> | (required) | Enclave specification (.etdl) |
--test-count <int> | 500 | Number of generated property tests to run |
--step-limit <int> | deprecated | Compatibility alias for --test-count |
--tmpdir <dir> | (required) | Temp directory |
--sancus <dir> | (required) | Sancus simulator root |
--commit <sha> | ef753b6 | Simulator git commit |
--sancus-master-key <hex> | (default) | Master key |
--debug | false | Debug logging |
--info | false | Info logging |
Output
Section titled “Output”QCheck test results are printed to stdout. On failure, the reported pair of traces differs in whether execution resets.
Quick example
Section titled “Quick example”cd alvie/code_build/default/bin/pbt.exe \ --att-spec1 ../../spec-lib/example/attacker.atdl \ --att-spec2 ../../spec-lib/example/attacker.atdl \ --encl-spec ../../spec-lib/example/enclave.etdl \ --tmpdir /tmp/alvie-pbt \ --sancus "$PWD/../../sancus-core-gap" \ --test-count 50 \ --infoSummary table
Section titled “Summary table”| Executable | Purpose | Needs simulator | Needs mCRL2 | Output |
|---|---|---|---|---|
learn.exe | Learn Mealy machine via L# | Yes | No | .dot model |
fa.exe | Find NI violations between two models | No | Yes | .dot witness graph |
exec.exe | Replay an input trace (debug) | Yes | No | stdout trace |
pbt.exe | Random NI testing (no model) | Yes | No | QCheck report |