Skip to content

Commit e17d1e3

Browse files
docs: use Unicode superscripts in DH notation, add paper refs for concrete instantiations
- DH notation: g^a → gᵃ, (g^a)^b = g^{ab} → (gᵃ)ᵇ = gᵃᵇ, etc. in both DocDH.lean and DH.lean source header - Add §2.5 page references (Bhargavan et al.) to all concrete instantiation claims: HKDF-SHA-256 (p. 473), AES-256-CBC+HMAC (p. 472), Kyber-1024 (p. 472), HKDF-SHA-256 in passive secrecy (p. 473)
1 parent 41a6087 commit e17d1e3

7 files changed

Lines changed: 68 additions & 114 deletions

File tree

PQXDHLean/X3DH/DH.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Diffie-Hellman as scalar multiplication over `[Field F] [Module F G]`.
88
99
| Textbook (multiplicative) | This file (additive) |
1010
|---------------------------|----------------------------------|
11-
| `g^a` | `a • G₀` |
12-
| `(g^a)^b = g^{ab}` | `b • (a • G₀) = (b * a) • G₀` |
13-
| `g^a · g^b = g^{a+b}` | `a • G₀ + b • G₀ = (a+b) • G₀` |
11+
| `gᵃ` | `a • G₀` |
12+
| `(gᵃ)ᵇ = gᵃᵇ` | `b • (a • G₀) = (b * a) • G₀` |
13+
| `gᵃ · gᵇ = gᵃ⁺ᵇ` | `a • G₀ + b • G₀ = (a+b) • G₀` |
1414
-/
1515
import Mathlib.Algebra.Module.Basic
1616

docs/PQXDHDocs/DocAEAD.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ associated data (AD). In X3DH/PQXDH:
2525
to both parties' identities, preventing key-mismatch attacks.
2626

2727
The concrete instantiation is AES-256 in CBC mode with HMAC
28-
(Encrypt-Then-MAC). The paper assumes IND-CPA and INT-CTXT,
29-
which together imply IND-CCA2 for AEAD schemes (section 2.5, assumption 3).
28+
(Encrypt-Then-MAC) (§2.5, p. 472, Bhargavan et al.). The paper
29+
assumes IND-CPA and INT-CTXT, which together imply IND-CCA2
30+
for AEAD schemes (section 2.5, assumption 3).
3031

3132
# Structure
3233

docs/PQXDHDocs/DocDH.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ apply directly without unfolding.
3636
The formalization uses additive group notation following the Mathlib
3737
convention, instead of the multiplicative notation from textbooks:
3838

39-
- `g^a` becomes `a • G₀` (scalar multiplication)
40-
- `(g^a)^b = g^{ab}` becomes `b • (a • G₀) = (b * a) • G₀`
41-
- `g^a * g^b = g^{a+b}` becomes `a • G₀ + b • G₀ = (a + b) • G₀`
39+
- `gᵃ` becomes `a • G₀` (scalar multiplication)
40+
- `(gᵃ)ᵇ = gᵃᵇ` becomes `b • (a • G₀) = (b * a) • G₀`
41+
- `gᵃ · gᵇ = gᵃ⁺ᵇ` becomes `a • G₀ + b • G₀ = (a + b) • G₀`
4242

4343
# Algebraic properties
4444

docs/PQXDHDocs/DocKDF.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ A KDF deterministically derives a fixed-size key from variable-length
1919
input material. In X3DH, the input is the concatenation of the
2020
DH outputs and the result is the session key (SK).
2121

22-
The concrete instantiation is HKDF (RFC 5869) with SHA-256.
22+
The concrete instantiation is HKDF (RFC 5869) with SHA-256
23+
2.5, p. 473, Bhargavan et al.).
2324

2425
Two formalizations coexist, modeling different aspects of the KDF.
2526

docs/PQXDHDocs/DocKEM.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ encapsulates to get (ct, ss), appends ss to her KDF input, and
2626
sends ct to Bob. Bob decapsulates to recover ss.
2727

2828
The concrete instantiation is Kyber-1024 (ML-KEM), a lattice-based
29-
KEM secure under the Module-LWE assumption. The paper assumes the
30-
KEM is IND-CCA (section 2.5, assumption 1.B).
29+
KEM secure under the Module-LWE assumption (§2.5, p. 472, Bhargavan
30+
et al.). The paper assumes the KEM is IND-CCA (section 2.5,
31+
assumption 1.B).
3132

3233
# Structure
3334

docs/PQXDHDocs/DocX3DHPassiveSecrecy.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ using VCV-io for security game definitions.
2222

2323
# Random Oracle Model
2424

25-
In the real protocol, the KDF (HKDF-SHA-256) is a deterministic
26-
function. In the security proof, we replace it with a *random
25+
In the real protocol, the KDF (HKDF-SHA-256, §2.5, p. 473) is a
26+
deterministic function. In the security proof, we replace it with a *random
2727
oracle*: a function that, on each new input, returns a uniformly
2828
random output and caches it for consistency (same input always
2929
gives the same output).

docs/README.md

Lines changed: 52 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,75 @@
1-
# Setting Up Verso-Blueprint
1+
# PQXDH Documentation Project
22

3-
This guide explains how to set up Verso-Blueprint documentation for a Lean 4 project.
3+
Verso-Blueprint documentation for the PQXDH Lean 4 formalization.
44

5-
## Prerequisites
5+
Built with [verso-blueprint](https://github.com/ejgallego/verso-blueprint) (v4.28.0),
6+
which extends [Verso](https://github.com/leanprover/verso) with blueprint-style
7+
rendering for mathematical formalizations.
68

7-
- A working Lean 4 project with `lakefile.toml`
8-
- `elan` installed
9+
## Dependencies
910

10-
## Directory Structure
11+
The docs project (`docs/lakefile.toml`) depends on:
1112

12-
```
13-
your-project/
14-
├── lakefile.toml # Main project lakefile
15-
├── lean-toolchain
16-
├── YourLib/ # Your Lean source files
17-
│ └── *.lean
18-
└── docs/
19-
├── lakefile.toml # Docs project lakefile
20-
├── lean-toolchain
21-
├── Main.lean
22-
└── YourDocs/ # Documentation source files
23-
└── *.lean
24-
```
25-
26-
## Step 1: Set Up the Docs Project
13+
- **versoBlueprint** — documentation framework (fetched from git)
14+
- **PQXDH-lean** — the parent Lean library (via `path = ".."`)
2715

28-
Create `docs/lakefile.toml`:
16+
Transitive dependencies (`subverso`, Verso core) are resolved automatically
17+
by Lake from the verso-blueprint manifest. The main project lakefile does
18+
**not** need to list them.
2919

30-
```toml
31-
name = "YourDocs"
32-
defaultTargets = ["YourDocs", "docs"]
20+
## Building
3321

34-
[[require]]
35-
name = "verso"
36-
git = "https://github.com/leanprover/verso"
37-
rev = "main" # or a specific commit
38-
39-
[[lean_lib]]
40-
name = "YourDocs"
41-
42-
[[lean_exe]]
43-
name = "docs"
44-
root = "Main"
45-
```
46-
47-
Create `docs/lean-toolchain` with the same Lean version as your main project.
48-
49-
## Step 2: Build the Docs Project
22+
From the repository root (not from `docs/`):
5023

5124
```bash
52-
cd docs
25+
# Build the Lean library first
5326
lake build
54-
```
55-
56-
This will fetch Verso and its dependencies, including `subverso`.
57-
58-
## Step 3: Add Subverso to the Main Project
59-
60-
Look up the `subverso` commit from `docs/lake-manifest.json`:
61-
62-
```bash
63-
grep -A2 '"name": "subverso"' docs/lake-manifest.json
64-
```
65-
66-
Add `subverso` (not `verso`) to your main project's `lakefile.toml`:
67-
68-
```toml
69-
[[require]]
70-
name = "subverso"
71-
git = "https://github.com/leanprover/subverso"
72-
rev = "<commit-from-lake-manifest>"
73-
```
7427

75-
## Step 4: Build the Main Project
28+
# Build the documentation executable
29+
lake -d docs build
7630

77-
Build with `--keep-toolchain` to prevent the lean-toolchain from updating to subverso's version:
78-
79-
```bash
80-
lake build --keep-toolchain
31+
# Generate HTML and serve locally
32+
./scripts/build-blueprint.sh
33+
python3 -m http.server 8080 -d _out/blueprint
8134
```
8235

83-
## Step 5: Configure Example Project Path
36+
Then open http://localhost:8080.
8437

85-
In your documentation Lean files, set the `verso.exampleProject` option to point to your main project:
38+
## Project structure
8639

87-
```lean
88-
set_option verso.exampleProject "."
8940
```
90-
91-
The path is relative to the workspace root when running `lake -d docs build` from the main project directory.
92-
93-
## Building Documentation
94-
95-
From the main project root:
96-
97-
```bash
98-
lake -d docs build docs
41+
docs/
42+
├── lakefile.toml # Depends on versoBlueprint + parent project
43+
├── lean-toolchain # Must match parent (v4.28.0)
44+
├── lake-manifest.json # Pinned dependency versions
45+
├── Main.lean # Entry point: CSS, JS, blueprint config
46+
├── PQXDHDocs.lean # Top-level document definition
47+
└── PQXDHDocs/
48+
├── Contents.lean # Imports all chapters, opens Verso namespaces
49+
├── SourceBlock.lean # Custom code block: extracts proof bodies from source
50+
├── DocDH.lean # Diffie-Hellman
51+
├── DocKDF.lean # Key Derivation Function
52+
├── DocAEAD.lean # Authenticated Encryption
53+
├── DocKEM.lean # Key Encapsulation Mechanism
54+
├── DocX3DH.lean # X3DH Protocol (includes PermDraws + PassiveSecrecy)
55+
├── DocPermDraws.lean # perm_draws Tactic (subsection of X3DH)
56+
├── DocX3DHPassiveSecrecy.lean # Passive Message Secrecy (subsection of X3DH)
57+
├── DocPQXDH.lean # PQXDH Protocol
58+
└── DocSecurityDefs.lean # Security Definitions and Assumptions
9959
```
10060

101-
Or create a build script (e.g., `scripts/build-blueprint.sh`):
102-
103-
```bash
104-
#!/usr/bin/env bash
105-
set -euo pipefail
106-
107-
cd "$(dirname "$0")/.."
108-
109-
out_root="${1:-_out/blueprint}"
110-
mkdir -p "$out_root"
61+
## How it works
11162

112-
lake -d docs build docs
113-
"docs/.lake/build/bin/docs" --output "$out_root"
114-
115-
echo "Output: $(readlink -f "$out_root")"
116-
```
63+
- Each `Doc*.lean` file is a Verso document chapter using `#doc (Manual)` blocks.
64+
- Definitions and theorems use `(lean := "DeclarationName")` to link prose
65+
to Lean declarations, which Verso resolves at elaboration time.
66+
- Proof bodies are extracted via `` ```source DeclarationName `` blocks
67+
(implemented in `SourceBlock.lean`), which read the actual source file
68+
and display the proof text.
69+
- Cross-references between chapters use `{uses "tag"}[]` where tags are
70+
defined by `:::definition` and `:::theorem` blocks.
11771

118-
## Serving the Documentation
119-
120-
```bash
121-
python3 -m http.server 8080 -d _out/blueprint
122-
```
72+
## Lean version
12373

124-
Then open http://localhost:8080 in your browser.
74+
Both the library and docs must use the same Lean toolchain. Currently
75+
`leanprover/lean4:v4.28.0`, matching Mathlib and verso-blueprint.

0 commit comments

Comments
 (0)