How roycesteven/dilithium-msc-project works
Purpose and entry points
This is a research implementation and evidence pipeline for post-quantum Lattice-based Adaptor Signatures (LAS) built from simplified Dilithium / ML-DSA primitives, with atomic-swap applications. Primary entry points are the C build in ref/Makefile, the Rust crate in rust/fips204-las/Cargo.toml, and reproducible experiment runners in scripts/run_benchmark_suite.sh and scripts/run_rust_bench_suite.sh.
Core C protocol implementation
The C implementation is the reference protocol stack. It defines shared public parameters and protocol object types, generates hard-relation statements/witnesses, implements the base signature, then implements adaptor operations: presign, preverify, adapt, and extract.
• ref/setup.c
• ref/relation.c
• ref/basesig.c
• ref/las.c
• ref/serialize.c
The cryptographic arithmetic and hashing boundary is the reused Dilithium-style polynomial/NTT/SHAKE substrate, rather than application code:
• ref/poly.c
• ref/ntt.c
• ref/fips202.c
Rust mirror and interoperability boundary
rust/fips204-las/ is a parallel Rust implementation intended to emit byte-identical protocol objects to C. Its public library surface is rooted in src/lib.rs; LAS logic, base signatures, relation construction, and canonical encoding are separated into matching modules.
• rust/fips204-las/src/lib.rs
• rust/fips204-las/src/las.rs
• rust/fips204-las/src/basesig.rs
• rust/fips204-las/src/serialize.rs
The key system invariant is cross-language wire compatibility, with deterministic known-answer testing serving as the gate before measurement or application use:
• ref/test/test_kat.c
• rust/fips204-las/tests/las_kat.rs
Proof and swap layer
The optional proof-of-knowledge layer proves knowledge of the relation witness used by the Figure-1-style atomic swap. C exposes relation-proof abstractions and backends, including the vendored-LaZer integration; the Rust port can use the same proof-system path through an opt-in feature.
• ref/relation_zk.c
• ref/relation_zk_lazer.c
• ref/test/test_swap.c
• rust/fips204-las/tests/las_swap.rs
A separate Rust swap crate models protocol orchestration, UTXO state, interchangeable LAS/ECDSA backends, and benchmarkable swap flows:
• rust/las-swap/src/protocol.rs
• rust/las-swap/src/utxo.rs
• rust/las-swap/src/las_backend.rs
Blockchain integration surfaces
Bitcoin integration has two levels: a standalone C consensus-oriented LAS verifier/tool and a patch against Bitcoin Script semantics, with Python drivers for transaction construction, spending, recovery, and model checks.
• bitcoin/las_consensus/las_consensus.c
• bitcoin/las_consensus/las_btc_tool.c
• bitcoin/patches/0001-op-checklassigverify-v31.1.patch
• bitcoin/tools/btc_las_spend.py
Ethereum integration is Solidity verification and swap/claim contracts, driven by Foundry scripts. Contract verification is distinct from swap state management.
• evm/src/LASVerifier.sol
• evm/src/AdaptorSwap.sol
• evm/src/AdaptorSwapBound.sol
• evm/script/TwoLeg.s.sol
These external-runtime boundaries require Bitcoin Core/regtest for node experiments and an EVM/Foundry environment for gas and transaction experiments.
Succinct-proof research branch
rust/las-stark/ is an independent Rust STARK proving/verification implementation for LAS relations and role-specific computations. It has CLI binaries for proof generation, verification, and benchmarking rather than being part of the C/Rust byte-identical signing path.
• rust/las-stark/src/air.rs
• rust/las-stark/src/prover.rs
• rust/las-stark/src/bin/prove_relation.rs
• rust/las-stark/src/bin/verify_relation.rs
Measurement-to-report pipeline
Correctness-gated benchmark drivers generate timestamped immutable evidence; scripts transform evidence into tables, plots, generated LaTeX macros, and the final report. Evidence also captures Bitcoin regtest and EVM receipts/calldata, preserving application-level outcomes separately from local microbenchmarks.
• scripts/run_benchmark_suite.sh
• scripts/gen_report_data.py
• evidence/runs/
• report/latex/report.tex
• report/latex/generated/
The architectural control flow is: implementations → interoperability/functional gates → benchmarks and blockchain experiments → timestamped evidence → generated report artifacts. Documentation maps mathematical construction and experimental claims back to implementation and evidence:
• docs/02-methodology/THEORY_IMPL_BRIDGE.md
• README_EXTENDED.md
Main entry points: las.c LAS protocol core · lib.rs Rust LAS library · test_kat.c C known-answer gate · las_kat.rs Rust known-answer gate
Components 23
C reference stack
- C build
ref/Makefile - LAS protocol core · Parameters, relations, base signatures, adaptor operations, and encoding.
ref/las.c - Relation construction
ref/relation.c - Dilithium arithmetic · Polynomial, NTT, and SHAKE primitives.
ref/poly.c - C known-answer gate
ref/test/test_kat.c - Relation proof layer · Optional witness proofs with a LaZer backend.
ref/relation_zk.c - C atomic-swap test
ref/test/test_swap.c
Rust implementations
- Rust LAS library · Byte-identical mirror of the C protocol surface.
rust/fips204-las/src/lib.rs - Rust adaptor logic
rust/fips204-las/src/las.rs - Rust known-answer gate
rust/fips204-las/tests/las_kat.rs - Swap orchestration · Models UTXOs and interchangeable LAS/ECDSA swap backends.
rust/las-swap/src/protocol.rs - STARK research branch · Independent LAS relation proving and verification path.
rust/las-stark/src/prover.rs - STARK proof CLI
rust/las-stark/src/bin/prove_relation.rs
Blockchain integrations
- Bitcoin LAS verifier · Standalone consensus-oriented verifier and transaction tool.
bitcoin/las_consensus/las_consensus.c - Bitcoin Script patch · Adds LAS verification semantics to Script.
bitcoin/patches/0001-op-checklassigverify-v31.1.patch - Bitcoin spend driver
bitcoin/tools/btc_las_spend.py - EVM LAS verifier
evm/src/LASVerifier.sol - EVM adaptor swap · Swap and bound-claim state management.
evm/src/AdaptorSwap.sol - EVM two-leg runner
evm/script/TwoLeg.s.sol
Evidence and report
- Benchmark runner · Runs correctness-gated C measurements.
scripts/run_benchmark_suite.sh - Timestamped evidence · Includes local benchmarks and chain experiment outcomes.
- Report data generator
scripts/gen_report_data.py - Final research report
report/latex/report.tex
Connections 26
- C build → LAS protocol core: builds
- LAS protocol core → Relation construction: constructs relations
- LAS protocol core → Dilithium arithmetic: uses
- LAS protocol core → C known-answer gate: validated by
- LAS protocol core → Relation proof layer: supplies witness relation
- Relation proof layer → C atomic-swap test: exercised by
- LAS protocol core → Rust LAS library: wire-compatible mirror
- Rust LAS library → Rust adaptor logic: exports
- Rust LAS library → Rust known-answer gate: validated by
- C known-answer gate → Rust known-answer gate: cross-language gate
- Rust LAS library → Swap orchestration: LAS backend
- Relation construction → STARK research branch: proves equivalent relations
- STARK research branch → STARK proof CLI: drives
- LAS protocol core → Bitcoin LAS verifier: verification semantics
- Bitcoin LAS verifier → Bitcoin Script patch: informs
- Bitcoin Script patch → Bitcoin spend driver: used in regtest experiments
- LAS protocol core → EVM LAS verifier: verification semantics
- EVM LAS verifier → EVM adaptor swap: verifies claims
- EVM adaptor swap → EVM two-leg runner: executed by
- C known-answer gate → Benchmark runner: correctness gate
- Rust known-answer gate → Benchmark runner: interoperability gate
- Benchmark runner → Timestamped evidence: writes measurements
- Bitcoin spend driver → Timestamped evidence: records regtest outcomes
- EVM two-leg runner → Timestamped evidence: records receipts and calldata
- Timestamped evidence → Report data generator: transforms
- Report data generator → Final research report: generates tables and macros