Commit dcf5ed5
proof(SafeOTP): annotate 5 bodyless decls as OWED (Refs standards#158) (#50)
## Summary
Converts the **5** bodyless declarations in
`src/Proven/SafeOTP/Proofs.idr` from terse `Postulated:` comments (or no
justification at all) to the estate's **OWED-with-justification**
convention established 2026-05-20 across SafeChecksum / Buffer /
CryptoAccel / HKDF / Bloom / FPGA, and continued in sibling PRs #37
(SafeAPIKey), #38 (SafeCORS), #39 (SafeCSV), #40 (SafeSemVer), #41
(SafeHtml), #46 (SafeMath):
- Triple-pipe `|||` doc-comment stating the claim
- `0 ` (erased multiplicity) so the postulate is not runtime-callable
- Bare signature, no `postulate` keyword (estate-wide choice)
- Explicit Idris2 0.8.0 blocker + discharge condition
Refs hyperpolymath/standards#158.
## The 5 OWED items
### 1. `constantTimeCompareRefl`
**Claim:** `constantTimeCompare s s = True` for every `String s`.
**Why OWED:** witnessed operationally — the `length as /= length bs`
guard collapses to `False`, then `go` folds `acc && (x == y)` with `x ==
y` true at every position. However, Idris2 0.8.0 does not reduce `unpack
s` (FFI-bound) at the type level, nor does it expose a `c == c = True`
Refl lemma for `prim__eq_Char`. Same blocker family as boj-server's
`Boj.SafetyLemmas.charEqSym` (discharged there as a class-(J) `%unsafe
believe_me` axiom).
**Discharge:** a `Data.String` / `Data.Char` reflective tactic, or a
class-(J) `charEqRefl` axiom plus per-list induction over `go`.
### 2. `constantTimeCompareSym`
**Claim:** `constantTimeCompare a b = constantTimeCompare b a`.
**Why OWED:** symmetric componentwise — length equality is symmetric,
Char equality is symmetric — but `prim__eq_Char` does not expose `(x ==
y) = (y == x)` as a Refl lemma, and `unpack` does not reduce. Same
blocker family as `constantTimeCompareRefl`.
**Discharge:** as above, plus a class-(J) `charEqSym` axiom.
### 3. `codeValidatesAgainstSelf`
**Claim:** `validateTOTPCode code [code] = True`.
**Why OWED:** direct downstream corollary of `constantTimeCompareRefl` —
definitional unfolding gives `constantTimeCompare code.code code.code ||
False`. Cannot be discharged until `constantTimeCompareRefl` is.
**Discharge:** immediate `rewrite` step once `constantTimeCompareRefl`
is in scope.
### 4. `codeInListValidates`
**Claim:** if `any (\e => constantTimeCompare code.code e.code) codes =
True` then `validateTOTPCode code codes = True`.
**Why OWED:** this is literally the function's body equality, but Idris2
0.8.0 does not eta-reduce the lambda inside `any` at the type level for
an abstract `codes`, and the `constantTimeCompare` underneath inherits
the String FFI opacity.
**Discharge:** induction on `codes` (one-line `Refl` for `[]`, `rewrite`
step for `_ :: _`) — can be inlined here, or pulled in once a
`Data.List.any` extensionality lemma lands in `contrib`.
### 5. `identicalHOTPValid`
**Claim:** `validateHOTPCode code code = True`.
**Why OWED:** direct downstream corollary of `constantTimeCompareRefl` —
`validateHOTPCode submitted expected = constantTimeCompare
submitted.code expected.code` reduces to `constantTimeCompare code.code
code.code` for identical inputs.
**Discharge:** immediate once `constantTimeCompareRefl` is in scope.
## Safety posture
- Zero `believe_me`
- Zero `postulate`
- Zero `idris_crash`
- All `0`-erased — postulates cannot leak into runtime
- All discoverable as named declarations (vs silent / commented-out)
## Scope
- Touches only `src/Proven/SafeOTP/Proofs.idr`
- The 10 Refl-discharged proofs in the file (divisors, default-period,
defaults, secret guards, empty-list rejection, etc.) are untouched
## Why draft
Estate CI is currently jammed on base-package dependency resolution (see
sibling SafeHtml PR #41 thread). DRAFT until CI is unjammed, at which
point owner can flip to ready-for-review.
## Test plan
- [ ] Idris2 0.8.0 `--check` on `src/Proven/SafeOTP/Proofs.idr` once CI
is unjammed
- [ ] Verify no downstream module shadows these names (grep was clean at
edit time)
- [ ] Owner review of OWED reasons against SafeChecksum + SafeHtml +
SafeAPIKey precedents
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 891ed45 commit dcf5ed5
1 file changed
Lines changed: 76 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
38 | 51 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
42 | 67 | | |
43 | | - | |
| 68 | + | |
44 | 69 | | |
45 | 70 | | |
46 | 71 | | |
| |||
51 | 76 | | |
52 | 77 | | |
53 | 78 | | |
54 | | - | |
55 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
56 | 92 | | |
57 | | - | |
| 93 | + | |
58 | 94 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
62 | 109 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
68 | 124 | | |
69 | | - | |
| 125 | + | |
70 | 126 | | |
71 | 127 | | |
72 | 128 | | |
| |||
0 commit comments