Skip to content
You are reading the current documentation of ALVIE: 2026.10. Other versions: development version, 2026.09 (extended documentation), 2026.09 (as released)

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.

FlagDescription
--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
FlagDefaultDescription
--commit <sha>ef753b6Label or git commit of the Sancus version to check
--secret <value>absentSecret substituted into the enclave specification; required when the spec contains ?
--epsilon <float>0.001PAC error bound, used only by pac
--delta <float>0.001PAC confidence parameter, used only by pac
--pac-bound <int>1Included in --report output only; does not limit the current PAC oracle
--step-limit <int>500Max steps for a random-walk equivalence query
--round-limit <int>unlimitedMax rounds for a PAC equivalence query
--reset-probability <float>0.05Random-walk probability of restarting the current path
--bad-probability <float>0.20Probability of generating an input not driven by the specification
--ignore-interruptsfalseTreat interrupts as invisible (collapse interrupt outputs)
--keep-repeated-reentriesfalseDo 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
--dryfalseDry run: set up the simulator but do not learn
--reportfalsePrint a line of learning statistics on stderr (see the log output reference)
--debugfalseEnable debug-level logging
--infofalseEnable info-level logging: one line per equivalence-query round and one per counterexample (see the log output reference)
VariableEffect
ALVIE_SIM_CACHEDirectory where compiled simulators are kept and reused (default: simv-cache inside --tmpdir); 0 always compiles. Also used by exec.exe and pbt.exe
ALVIE_PROFILEWith 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_APARTWith 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_TRACEWith 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
OCAMLRUNPARAMGarbage collector settings; when it is set, learn.exe does not apply its own

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.

Terminal window
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" \
--info

This learns a model for the example attack with secret=0 using random-walk equivalence queries, writing the result to /tmp/example-s0.dot.

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.

FlagDefaultDescription
--m1-int <file>(required)secret=0 model, interrupt variant (.dot)
--m2-int <file>(required)secret=1 model, interrupt variant (.dot)
--m1-nint <file>optionalsecret=0 no-interrupt model (.dot)
--m2-nint <file>optionalsecret=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>unlimitedMaximum number of counterexamples to enumerate
--debugfalseEnable debug-level logging

<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.

Terminal window
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 3

Produces /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):

FlagDescription
--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-interruptsCollapse interrupt outputs
--sancus-master-key <hex>Master key
--debugDebug logging

Prints one line per step to stdout: the input sent and the output received from the simulator.

Terminal window
cd alvie/code
cat > /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" \
--debug

4. 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.

FlagDefaultDescription
--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>500Number of generated property tests to run
--step-limit <int>deprecatedCompatibility alias for --test-count
--tmpdir <dir>(required)Temp directory
--sancus <dir>(required)Sancus simulator root
--commit <sha>ef753b6Simulator git commit
--sancus-master-key <hex>(default)Master key
--debugfalseDebug logging
--infofalseInfo logging

QCheck test results are printed to stdout. On failure, the reported pair of traces differs in whether execution resets.

Terminal window
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 \
--info

ExecutablePurposeNeeds simulatorNeeds mCRL2Output
learn.exeLearn Mealy machine via L#YesNo.dot model
fa.exeFind NI violations between two modelsNoYes.dot witness graph
exec.exeReplay an input trace (debug)YesNostdout trace
pbt.exeRandom NI testing (no model)YesNoQCheck report