# s2n-bignum

> Prove hand-written x86-64 or Arm64 assembly correct in HOL Light, on the exact bytes of the built object file; used for AWS's cryptography code.

- Kind: toolchain
- Verifies: x86-64 (Library routines for bignums, elliptic curves, ML-KEM, ML-DSA and SHA-3; some need the BMI and ADX extensions (MULX, ADCX, ADOX).); AArch64 (Library routines for bignums, elliptic curves, ML-KEM, ML-DSA, SHA-3, AES-XTS and AES-GCM; some need crypto extensions.)
- Effort: Interactive — You write proofs step by step in a proof assistant.
- Stage: 1 (Usable)
- Trust: Checker strong, Semantics partial, Frontend strong, Binary gap strong, Escape hatches strong
- Licence: open-source, Apache-2.0 OR ISC OR MIT-0
- Latest release: main@3ab28d2 (2026-11-26) https://github.com/awslabs/s2n-bignum/commits/main
- Links: [repo](https://github.com/awslabs/s2n-bignum), [docs](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md), [paper](https://arxiv.org/abs/2505.14348), [tutorial](https://github.com/awslabs/s2n-bignum/tree/main/arm/tutorial)

## Use it if
- You write performance-critical assembly (for example cryptography) and need proofs about the object code that actually ships.
- You also need constant-time, memory-safety or equivalence proofs (for example after vectorizing or reordering code).

## Look elsewhere if
- Your code uses system instructions, interrupts, floating point or threads; the machine models are user-mode, integer/SIMD and single-core.
- You want push-button checking; proofs are written by hand in HOL Light with tactic support.

## How it works (pipeline)

| Step | Component | Assurance | Note |
|---|---|---|---|
| frontend | OCaml ELF loader (reads the .text bytes of the built object file) | trusted | The soundness review notes a loader error would usually make the proof fail rather than pass wrongly. |
| semantics | s2n-bignum x86-64 model (hand-written in HOL Light) | validated | Instructions are added as needed; tested by random co-simulation against real hardware in CI. |
| semantics | s2n-bignum AArch64 model (hand-written in HOL Light) | validated | Instructions are added as needed; tested by random co-simulation in CI. A partial RV32IM RISC-V model was added in September 2026, with tutorial examples only. |
| translation | Symbolic simulation tactics in HOL Light | checked |  |
| checker | HOL Light kernel (`hol-light`) | trusted |  |
| compiler | Assembler (GNU as via gcc or another) | validated | Each proof checks its byte sequence against the object file from the build. Projects that reassemble the .S files elsewhere do not get this check. |

## Trust

| Axis | Level | Summary | Note |
|---|---|---|---|
| Checker | Strong (green) | The HOL Light kernel (about 400 lines of OCaml) checks every proof. | OCaml's compiler and runtime are also trusted. Independent re-checking is possible in principle (Candle, HOLTrace) but not part of the build. [source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md) |
| Semantics | Partial (amber) | Hand-written instruction models; random co-simulation against real CPUs in CI. | Models are written from the Intel/AMD and Arm manuals, not taken from an official model. CI compares random instruction encodings and states against an independent backend (hardware, an emulator or another model); we found no published report of these results. [source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md) |
| Frontend | Strong (green) | The proved bytes are checked against the object file produced by the build. |  [source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md) |
| Binary gap | Strong (green) | Proofs are about the object code; the assembler is not trusted. | Downstream projects that reassemble the .S files on another system are not checked against the proved bytes. [source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md) |
| Escape hatches | Strong (green) | Every proof build runs check_axioms, which fails if any extra axiom was added. |  [source](https://github.com/awslabs/s2n-bignum/blob/main/tools/build-proof.sh) |

## What it can prove

| Property | Support |
|---|---|
| No undefined behavior | Partial — Memory-safety proofs (all accesses inside the declared buffers) exist for the functions AWS-LC uses, not yet for the whole library. They do not check accesses below the stack pointer, and the memory model has no unmapped pages, so the caller must pass mapped memory. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |
| Functional correctness | Supported — Each function has a HOL Light theorem that the code computes a mathematical specification for all inputs. ([source](https://github.com/awslabs/s2n-bignum#testing-and-formal-verification)) |
| Equivalence | Supported — A relational Hoare logic (CAV 2025) is used to prove optimized code (NEON vectorization, SLOTHY reordering) equivalent to a reference version. ([source](https://github.com/awslabs/s2n-bignum/blob/main/doc/program_equivalence.md)) |
| Information flow | Supported — Since late 2025, constant-time proofs show the instruction sequence and memory addresses do not depend on secrets and no variable-time instructions are used; done for the functions AWS-LC uses. They cannot rule out timing differences inside the hardware. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |
| Concurrency | Not supported — The machine model is sequential and single-core. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |
| Termination and liveness | Supported — Specifications state that execution eventually reaches the postcondition (total correctness). ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |

## ISA-level features

| Feature | Support |
|---|---|
| User-level instructions | Partial — Only the user-mode integer, load/store and branch instructions needed so far are modeled ("modeled by need"). ([source](https://github.com/awslabs/s2n-bignum/blob/main/arm/INSTRUCTION.md)) |
| Floating-point instructions | Not supported — No floating-point arithmetic; on Arm only register moves such as FMOV and FCSEL are modeled. ([source](https://github.com/awslabs/s2n-bignum/blob/main/arm/proofs/instruction.ml)) |
| Vector / SIMD instructions | Partial — A subset of Arm NEON (including AES, SHA-3 and polynomial-multiply instructions) and of x86 SSE/AVX, added as needed. ([source](https://github.com/awslabs/s2n-bignum/blob/main/x86/INSTRUCTION.md)) |
| Privileged mode | Not supported — No system registers, privilege levels, interrupts or exceptions. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |
| Virtual memory | Not supported — Flat address space; no page tables or page faults. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |
| Concurrency memory model | Not supported — No caches, memory ordering or multiple cores. ([source](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)) |

## Stage

**Stage 1: Usable.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Publicly available | yes | [evidence](https://github.com/awslabs/s2n-bignum) |
| 0 | At least one published verification uses it | yes | [evidence](https://arxiv.org/abs/2505.14348) Relational Hoare Logic for Realistically Modelled Machine Code (CAV 2025), demonstrated on s2n-bignum. |
| 1 | Released or updated in the last 12 months | yes | [evidence](https://github.com/awslabs/s2n-bignum/commits/main) Latest release: main@3ab28d2, 2026-11-26. |
| 1 | Installs and runs on current platforms | yes | [evidence](https://github.com/awslabs/s2n-bignum/actions) CI on main passes (checked 2026-11-26); proofs need a recent HOL Light from GitHub. |
| 1 | User documentation or tutorial | yes | [evidence](https://github.com/awslabs/s2n-bignum/tree/main/arm/tutorial) README, tutorials for Arm and x86, instruction-modeling guides and a soundness review. |
| 1 | Used by a group other than its authors | yes | [evidence](https://github.com/pq-code-package/mlkem-native) mlkem-native (PQ Code Package) proves its AArch64 and x86-64 assembly with the s2n-bignum infrastructure; some of its maintainers also work at AWS. The CAV 2025 paper has co-authors from CMU and Stanford. |
| 2 | Verified code in production at two or more independent organizations | no | 1 recorded: Amazon Web Services. |
| 2 | Checker axis is not red | yes |  |
| 2 | Semantics axis is not red | yes |  |
| 2 | Public channel for soundness bugs | yes | [evidence](https://github.com/awslabs/s2n-bignum/issues) Public issue tracker; security issues go through AWS vulnerability reporting (see CONTRIBUTING.md). |

Missing for Stage 2: Verified code in production at two or more independent organizations.

## In production
- Amazon Web Services: AWS-LC, the cryptographic library that AWS managed services such as AWS KMS rely on, uses machine-checked code from s2n-bignum (per the AWS Security Blog, Nov 2026). ([source](https://aws.amazon.com/blogs/security/make-post-quantum-cryptography-updates-routine-with-aws-lc/))

## Projects
- [AWS-LC elliptic-curve, RSA and Montgomery arithmetic](https://aws.amazon.com/blogs/security/aws-lc-fips-3-0-first-cryptographic-library-to-include-ml-kem-in-fips-140-3-validation/)
- [mlkem-native AArch64 and x86-64 assembly (functional correctness, memory safety, constant time)](https://github.com/pq-code-package/mlkem-native)

## Sources
- [s2n-bignum README](https://github.com/awslabs/s2n-bignum)
- [s2n-bignum soundness review](https://github.com/awslabs/s2n-bignum/blob/main/SOUNDNESS.md)
- [Program equivalence proofs](https://github.com/awslabs/s2n-bignum/blob/main/doc/program_equivalence.md)
- [Arm instruction modeling](https://github.com/awslabs/s2n-bignum/blob/main/arm/INSTRUCTION.md)
- [x86-64 instruction modeling](https://github.com/awslabs/s2n-bignum/blob/main/x86/INSTRUCTION.md)
- [Partial RISC-V (RV32IM) model](https://github.com/awslabs/s2n-bignum/tree/main/riscv)
- [HOL Light check_axioms](https://github.com/jrh13/hol-light/blob/master/Help/check_axioms.hlp)
- [Relational Hoare Logic for Realistically Modelled Machine Code (CAV 2025)](https://arxiv.org/abs/2505.14348)
- [AWS Security Blog, 25 Nov 2026](https://aws.amazon.com/blogs/security/make-post-quantum-cryptography-updates-routine-with-aws-lc/)
- [AWS open-source cryptography page](https://aws.amazon.com/security/opensource/cryptography/)

---
Last checked 2026-11-26. Data: [JSON](/toolchains/s2n-bignum.json) · Page: [HTML](/toolchains/s2n-bignum/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
