aetherproof 0.5.0__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aetherproof-0.5.2/PKG-INFO +198 -0
- aetherproof-0.5.2/README.md +165 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/__init__.py +11 -11
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/auto.py +0 -1
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/cli.py +0 -1
- aetherproof-0.5.2/aetherproof/contract.py +48 -0
- aetherproof-0.5.2/aetherproof/core/anchor.py +143 -0
- aetherproof-0.5.2/aetherproof/core/evidence.py +50 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/hash.py +18 -18
- aetherproof-0.5.2/aetherproof/core/instruction.py +290 -0
- aetherproof-0.5.2/aetherproof/core/keyprotect.py +71 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/keystore.py +32 -5
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/log.py +431 -428
- aetherproof-0.5.2/aetherproof/core/payouts.py +260 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/receipt.py +294 -294
- aetherproof-0.5.2/aetherproof/core/reconcile.py +363 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/session.py +353 -371
- aetherproof-0.5.2/aetherproof/core/settlement.py +140 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/signer.py +2 -5
- aetherproof-0.5.2/aetherproof/core/timestamp.py +228 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/verifier.py +179 -181
- aetherproof-0.5.2/aetherproof/server.py +658 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/ui/display.py +306 -303
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/ui/easy_mode.py +0 -13
- aetherproof-0.5.2/aetherproof/ui/expert_mode.py +850 -0
- aetherproof-0.5.2/aetherproof.egg-info/PKG-INFO +198 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof.egg-info/SOURCES.txt +22 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof.egg-info/requires.txt +4 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/pyproject.toml +78 -73
- aetherproof-0.5.2/tests/security/README.md +32 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_hardening_v13.py +0 -3
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_parsing_and_types.py +0 -1
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_v12_extensions.py +0 -1
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/stress/full_audit.py +4 -5
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/stress/industrial_stress.py +0 -1
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/stress/isolation_audit.py +1 -2
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_auto.py +29 -9
- aetherproof-0.5.2/tests/test_cli_instruction.py +90 -0
- aetherproof-0.5.2/tests/test_cli_reconcile.py +123 -0
- aetherproof-0.5.2/tests/test_contract.py +136 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_core_coverage.py +6 -5
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_display.py +0 -1
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_easy_mode.py +0 -2
- aetherproof-0.5.2/tests/test_evidence.py +70 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_expert_mode.py +0 -2
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_independent_verification.py +33 -9
- aetherproof-0.5.2/tests/test_instruction.py +209 -0
- aetherproof-0.5.2/tests/test_merkle_vectors.py +45 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_native_security.py +261 -261
- aetherproof-0.5.2/tests/test_payouts.py +174 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_readme_verifier.py +3 -3
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_receipt.py +0 -2
- aetherproof-0.5.2/tests/test_reconcile.py +228 -0
- aetherproof-0.5.2/tests/test_server.py +338 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_session_binding.py +0 -1
- aetherproof-0.5.2/tests/test_settlement.py +151 -0
- aetherproof-0.5.2/tests/test_timestamp_anchor.py +356 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_verifier.py +1 -3
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_verify_wizard.py +0 -1
- aetherproof-0.5.2/tests/test_version_consistency.py +71 -0
- aetherproof-0.5.0/PKG-INFO +0 -218
- aetherproof-0.5.0/README.md +0 -188
- aetherproof-0.5.0/aetherproof/ui/expert_mode.py +0 -444
- aetherproof-0.5.0/aetherproof.egg-info/PKG-INFO +0 -218
- aetherproof-0.5.0/tests/security/README.md +0 -27
- {aetherproof-0.5.0 → aetherproof-0.5.2}/LICENSE +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/MANIFEST.in +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/__main__.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/core/__init__.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/ui/__init__.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof/ui/menus.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof.egg-info/dependency_links.txt +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof.egg-info/entry_points.txt +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/aetherproof.egg-info/top_level.txt +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/setup.cfg +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/conftest.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_cli_contract.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_cloud_api_attested.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_cloud_models_matrix.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/security/test_preimage_injectivity.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_cli_entry.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_cli_paths.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_key_rotation.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_log.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_native_equivalence.py +0 -0
- {aetherproof-0.5.0 → aetherproof-0.5.2}/tests/test_session.py +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aetherproof
|
|
3
|
+
Version: 0.5.2
|
|
4
|
+
Summary: Signed payout instructions, a fail-closed payment gate, payout and bank settlement reconciliation, and offline-verifiable evidence.
|
|
5
|
+
Author-email: Pulkit Kr Srivastava <pulkitsrivastavae@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: cryptography,ai,audit,compliance,ed25519,receipt,tamper-evident
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Security :: Cryptography
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: cryptography>=41.0.0
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Requires-Dist: questionary>=2.0.0
|
|
24
|
+
Provides-Extra: timestamp
|
|
25
|
+
Requires-Dist: asn1crypto>=1.5.1; extra == "timestamp"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: asn1crypto>=1.5.1; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# AetherProof
|
|
35
|
+
|
|
36
|
+
**Proof of authority for payouts and other consequential actions.**
|
|
37
|
+
|
|
38
|
+
The system that approves a payout signs exactly what it approved. The system that
|
|
39
|
+
executes it checks that signature before money moves, and each instruction pays once.
|
|
40
|
+
Afterwards, provider records and the bank statement are matched back to the signed
|
|
41
|
+
instruction. A stolen API credential can still call a payout API, but it cannot create
|
|
42
|
+
a valid instruction.
|
|
43
|
+
|
|
44
|
+
Status: **0.5.2, evaluation build.** Tested on synthetic data only. No production
|
|
45
|
+
deployment, no live provider or bank connector, no independent security audit.
|
|
46
|
+
|
|
47
|
+
**Join the waitlist:** https://aetherproof.vercel.app/
|
|
48
|
+
|
|
49
|
+
## What it does
|
|
50
|
+
|
|
51
|
+
| Layer | What it does | Docs |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| Signed instructions | The approver signs amount, currency, beneficiary and validity window (Ed25519) | [SIGNED-INSTRUCTION-SPEC.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/SIGNED-INSTRUCTION-SPEC.md) |
|
|
54
|
+
| Payment gate | The executor verifies before paying. A replay store makes each instruction pay once, and the gate fails closed | same |
|
|
55
|
+
| Payout verification | Provider records (RazorpayX shaped, generic CSV/JSON) against instructions: matched, conflict, missing, pending. Payouts with no instruction are flagged | [USER_GUIDE.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) |
|
|
56
|
+
| Settlement evidence | Bank statement against provider status. A "processed" payout the bank never debited is a conflict | same |
|
|
57
|
+
| Evidence packages | A run sealed and signed. An auditor checks it offline with your public key | same |
|
|
58
|
+
| Checkpoints and time | Hash-chained log, signed checkpoints, RFC 3161 time stamps | [RECONCILIATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/RECONCILIATION.md) |
|
|
59
|
+
| Action reconciliation | Automated and agent actions against AWS CloudTrail | same |
|
|
60
|
+
| Receipts | Signed, offline verifiable receipts for model output (the original SDK) | [GETTING-STARTED.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/GETTING-STARTED.md) |
|
|
61
|
+
| Local API and desktop app | `/api/v1` with roles, lockout, rate limit and a hash-chained audit log | [API_CONTRACT.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/API_CONTRACT.md) |
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/pulkit6732/aetherproof
|
|
67
|
+
cd aetherproof
|
|
68
|
+
pip install -e ".[timestamp]"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`pip install aetherproof` currently installs 0.5.1 from PyPI, which has receipts only.
|
|
72
|
+
|
|
73
|
+
## Quick start
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# approver: sign what was approved
|
|
77
|
+
aetherproof instruction sign --amount 48500.00 --currency INR --beneficiary-token fa_123 \
|
|
78
|
+
--reference LN-1041 --approval-ref SAN-7701 --approved-by credit-ops
|
|
79
|
+
|
|
80
|
+
# executor: check before paying (exit 0 = allow, 1 = reject)
|
|
81
|
+
aetherproof instruction verify ~/.aetherproof/instructions/<id>.json \
|
|
82
|
+
--amount 48500.00 --currency INR --beneficiary-token fa_123 --reference <id>
|
|
83
|
+
|
|
84
|
+
# afterwards: provider export and bank statement against the instructions
|
|
85
|
+
aetherproof payouts reconcile payouts.json --instructions ~/.aetherproof/instructions \
|
|
86
|
+
--source razorpayx --statement statement.csv
|
|
87
|
+
|
|
88
|
+
# auditor: offline tamper check of a signed evidence package
|
|
89
|
+
aetherproof evidence verify run.evidence.json --pubkey signing_key.pub
|
|
90
|
+
|
|
91
|
+
# local API for the desktop app
|
|
92
|
+
aetherproof serve
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The [user guide](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) covers the three minute demo, the daily workflow,
|
|
96
|
+
file formats and how an auditor checks evidence.
|
|
97
|
+
|
|
98
|
+
## Desktop app
|
|
99
|
+
|
|
100
|
+
`app/` is a desktop client for the local API, built with
|
|
101
|
+
[Rune](https://github.com/anomalyco/rune). Screens: Overview, Instructions, Payment gate,
|
|
102
|
+
Payouts, Transaction investigation, Evidence, Integrations, Settings and security.
|
|
103
|
+
|
|
104
|
+
Rune is pre release, so the app builds against a local checkout placed next to this
|
|
105
|
+
repository, at `../vendor/rune` from the repository root, pinned to rev `ba5e7c80`.
|
|
106
|
+
Then run `aetherproof serve` and `cargo run --release` in `app/`. Every screen also
|
|
107
|
+
renders headless: `aetherproof-app --scene payouts --snap payouts.png`.
|
|
108
|
+
|
|
109
|
+

|
|
110
|
+
|
|
111
|
+
## Receipts
|
|
112
|
+
|
|
113
|
+
The receipt SDK signs a prompt and output pair so anyone can later check that the
|
|
114
|
+
record was not changed.
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from aetherproof.auto import sign
|
|
118
|
+
|
|
119
|
+
sign(prompt=user_prompt, output=out, model_id=resp.model)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
It never blocks your program. On failure it returns `None`; set `AETHERPROOF_STRICT=1`
|
|
123
|
+
to make a missing receipt an error. Decorator and session forms are in
|
|
124
|
+
[INTEGRATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/INTEGRATION.md).
|
|
125
|
+
|
|
126
|
+
Verification needs one dependency (`cryptography`), no network and no account. The
|
|
127
|
+
complete offline verifier, tested on every commit, is in
|
|
128
|
+
[VERIFICATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/VERIFICATION.md).
|
|
129
|
+
|
|
130
|
+
## What it proves
|
|
131
|
+
|
|
132
|
+
| Claim | Mechanism |
|
|
133
|
+
|---|---|
|
|
134
|
+
| The payout matched what was approved | Signed instruction checked at the gate |
|
|
135
|
+
| An instruction paid at most once | Replay store at the gate, fail closed |
|
|
136
|
+
| The provider's record agrees with the bank | Statement match in settlement evidence |
|
|
137
|
+
| Evidence was not altered after sealing | Signed evidence package, offline verify |
|
|
138
|
+
| The local log was not edited, reordered or cut in the middle | Hash chain plus signed checkpoints |
|
|
139
|
+
|
|
140
|
+
## What it does not prove
|
|
141
|
+
|
|
142
|
+
Read this before quoting anything above. Full list: [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md).
|
|
143
|
+
|
|
144
|
+
| Not proven | Why |
|
|
145
|
+
|---|---|
|
|
146
|
+
| Payouts that bypass the gate | The gate only protects payouts routed through it; a direct provider API call skips it |
|
|
147
|
+
| Business facts behind an approval | A signature proves who approved, not that the approval was right |
|
|
148
|
+
| Authentic bank data | Statements are imported files, not authenticated feeds |
|
|
149
|
+
| Safety against a stolen signing key | Whoever holds the key can sign valid instructions |
|
|
150
|
+
| Safety against one insider forging both files | Provider export and statement forged together stay consistent |
|
|
151
|
+
| That every event was logged | Integrity, not completeness; that needs an independent witness |
|
|
152
|
+
| That a named model produced an output | A receipt signs the model and output pair you supply |
|
|
153
|
+
|
|
154
|
+
## Two implementations
|
|
155
|
+
|
|
156
|
+
| | Python, `aetherproof/` | Rust, `rust/` |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| Signatures | Ed25519 | Ed25519, plus ML-DSA-65 (FIPS 204) in the Rust core |
|
|
159
|
+
| Secret wiping, constant time compare | no | yes |
|
|
160
|
+
| Distribution | PyPI | source and CI wheels |
|
|
161
|
+
|
|
162
|
+
The Rust core is optional. The Python package does not import it, which CI enforces.
|
|
163
|
+
The 128 byte Rust receipt is a legacy format whose hash fields are 64 bit FNV-1a
|
|
164
|
+
checksums, not cryptographic hashes; see [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md).
|
|
165
|
+
|
|
166
|
+
## Tests
|
|
167
|
+
|
|
168
|
+
Local results on Windows, synthetic data only, not production accuracy:
|
|
169
|
+
|
|
170
|
+
* Python suite, 18 Nov 2026: 900 passed, 0 skipped (`python -m pytest tests/`)
|
|
171
|
+
* Rust core, 18 Nov 2026: 62 passed (`cargo test --release --workspace` in `rust/`)
|
|
172
|
+
* Attack lab, 12 Nov 2026, 100k payouts: 0 of 94,400 clean payouts flagged; forged
|
|
173
|
+
"processed" status caught 500 of 500 with the statement (`python bench/attack_lab.py 100000`)
|
|
174
|
+
* Unknown attack fuzz, 12 Nov 2026: 0 fail open in 60,000 mutated cases
|
|
175
|
+
(`python bench/unknown_attacks.py 60000`)
|
|
176
|
+
|
|
177
|
+
Rerun them before quoting.
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
| | |
|
|
182
|
+
|---|---|
|
|
183
|
+
| [USER_GUIDE.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) | install, demo, workflow, file formats |
|
|
184
|
+
| [SIGNED-INSTRUCTION-SPEC.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/SIGNED-INSTRUCTION-SPEC.md) | instruction format, gate, payout checks |
|
|
185
|
+
| [API_CONTRACT.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/API_CONTRACT.md) | local API `/api/v1` |
|
|
186
|
+
| [RECONCILIATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/RECONCILIATION.md) | CloudTrail, checkpoints, RFC 3161 time |
|
|
187
|
+
| [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md) | what this proves and what it does not |
|
|
188
|
+
| [VERIFICATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/VERIFICATION.md) | the offline receipt verifier |
|
|
189
|
+
| [INTEGRATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/INTEGRATION.md) | receipt integration paths |
|
|
190
|
+
| [SECURITY.md](https://github.com/pulkit6732/aetherproof/blob/main/SECURITY.md) | reporting a vulnerability, threat model |
|
|
191
|
+
| [ROADMAP.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/ROADMAP.md) | what is planned |
|
|
192
|
+
| [CONTRIBUTING.md](https://github.com/pulkit6732/aetherproof/blob/main/CONTRIBUTING.md) | how to contribute |
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
Apache-2.0. Versions up to 0.2.2 were AGPL-3.0-or-later.
|
|
197
|
+
|
|
198
|
+
Security issues: see [SECURITY.md](https://github.com/pulkit6732/aetherproof/blob/main/SECURITY.md). Please do not open a public issue.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# AetherProof
|
|
2
|
+
|
|
3
|
+
**Proof of authority for payouts and other consequential actions.**
|
|
4
|
+
|
|
5
|
+
The system that approves a payout signs exactly what it approved. The system that
|
|
6
|
+
executes it checks that signature before money moves, and each instruction pays once.
|
|
7
|
+
Afterwards, provider records and the bank statement are matched back to the signed
|
|
8
|
+
instruction. A stolen API credential can still call a payout API, but it cannot create
|
|
9
|
+
a valid instruction.
|
|
10
|
+
|
|
11
|
+
Status: **0.5.2, evaluation build.** Tested on synthetic data only. No production
|
|
12
|
+
deployment, no live provider or bank connector, no independent security audit.
|
|
13
|
+
|
|
14
|
+
**Join the waitlist:** https://aetherproof.vercel.app/
|
|
15
|
+
|
|
16
|
+
## What it does
|
|
17
|
+
|
|
18
|
+
| Layer | What it does | Docs |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| Signed instructions | The approver signs amount, currency, beneficiary and validity window (Ed25519) | [SIGNED-INSTRUCTION-SPEC.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/SIGNED-INSTRUCTION-SPEC.md) |
|
|
21
|
+
| Payment gate | The executor verifies before paying. A replay store makes each instruction pay once, and the gate fails closed | same |
|
|
22
|
+
| Payout verification | Provider records (RazorpayX shaped, generic CSV/JSON) against instructions: matched, conflict, missing, pending. Payouts with no instruction are flagged | [USER_GUIDE.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) |
|
|
23
|
+
| Settlement evidence | Bank statement against provider status. A "processed" payout the bank never debited is a conflict | same |
|
|
24
|
+
| Evidence packages | A run sealed and signed. An auditor checks it offline with your public key | same |
|
|
25
|
+
| Checkpoints and time | Hash-chained log, signed checkpoints, RFC 3161 time stamps | [RECONCILIATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/RECONCILIATION.md) |
|
|
26
|
+
| Action reconciliation | Automated and agent actions against AWS CloudTrail | same |
|
|
27
|
+
| Receipts | Signed, offline verifiable receipts for model output (the original SDK) | [GETTING-STARTED.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/GETTING-STARTED.md) |
|
|
28
|
+
| Local API and desktop app | `/api/v1` with roles, lockout, rate limit and a hash-chained audit log | [API_CONTRACT.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/API_CONTRACT.md) |
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/pulkit6732/aetherproof
|
|
34
|
+
cd aetherproof
|
|
35
|
+
pip install -e ".[timestamp]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`pip install aetherproof` currently installs 0.5.1 from PyPI, which has receipts only.
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# approver: sign what was approved
|
|
44
|
+
aetherproof instruction sign --amount 48500.00 --currency INR --beneficiary-token fa_123 \
|
|
45
|
+
--reference LN-1041 --approval-ref SAN-7701 --approved-by credit-ops
|
|
46
|
+
|
|
47
|
+
# executor: check before paying (exit 0 = allow, 1 = reject)
|
|
48
|
+
aetherproof instruction verify ~/.aetherproof/instructions/<id>.json \
|
|
49
|
+
--amount 48500.00 --currency INR --beneficiary-token fa_123 --reference <id>
|
|
50
|
+
|
|
51
|
+
# afterwards: provider export and bank statement against the instructions
|
|
52
|
+
aetherproof payouts reconcile payouts.json --instructions ~/.aetherproof/instructions \
|
|
53
|
+
--source razorpayx --statement statement.csv
|
|
54
|
+
|
|
55
|
+
# auditor: offline tamper check of a signed evidence package
|
|
56
|
+
aetherproof evidence verify run.evidence.json --pubkey signing_key.pub
|
|
57
|
+
|
|
58
|
+
# local API for the desktop app
|
|
59
|
+
aetherproof serve
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The [user guide](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) covers the three minute demo, the daily workflow,
|
|
63
|
+
file formats and how an auditor checks evidence.
|
|
64
|
+
|
|
65
|
+
## Desktop app
|
|
66
|
+
|
|
67
|
+
`app/` is a desktop client for the local API, built with
|
|
68
|
+
[Rune](https://github.com/anomalyco/rune). Screens: Overview, Instructions, Payment gate,
|
|
69
|
+
Payouts, Transaction investigation, Evidence, Integrations, Settings and security.
|
|
70
|
+
|
|
71
|
+
Rune is pre release, so the app builds against a local checkout placed next to this
|
|
72
|
+
repository, at `../vendor/rune` from the repository root, pinned to rev `ba5e7c80`.
|
|
73
|
+
Then run `aetherproof serve` and `cargo run --release` in `app/`. Every screen also
|
|
74
|
+
renders headless: `aetherproof-app --scene payouts --snap payouts.png`.
|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
## Receipts
|
|
79
|
+
|
|
80
|
+
The receipt SDK signs a prompt and output pair so anyone can later check that the
|
|
81
|
+
record was not changed.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from aetherproof.auto import sign
|
|
85
|
+
|
|
86
|
+
sign(prompt=user_prompt, output=out, model_id=resp.model)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
It never blocks your program. On failure it returns `None`; set `AETHERPROOF_STRICT=1`
|
|
90
|
+
to make a missing receipt an error. Decorator and session forms are in
|
|
91
|
+
[INTEGRATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/INTEGRATION.md).
|
|
92
|
+
|
|
93
|
+
Verification needs one dependency (`cryptography`), no network and no account. The
|
|
94
|
+
complete offline verifier, tested on every commit, is in
|
|
95
|
+
[VERIFICATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/VERIFICATION.md).
|
|
96
|
+
|
|
97
|
+
## What it proves
|
|
98
|
+
|
|
99
|
+
| Claim | Mechanism |
|
|
100
|
+
|---|---|
|
|
101
|
+
| The payout matched what was approved | Signed instruction checked at the gate |
|
|
102
|
+
| An instruction paid at most once | Replay store at the gate, fail closed |
|
|
103
|
+
| The provider's record agrees with the bank | Statement match in settlement evidence |
|
|
104
|
+
| Evidence was not altered after sealing | Signed evidence package, offline verify |
|
|
105
|
+
| The local log was not edited, reordered or cut in the middle | Hash chain plus signed checkpoints |
|
|
106
|
+
|
|
107
|
+
## What it does not prove
|
|
108
|
+
|
|
109
|
+
Read this before quoting anything above. Full list: [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md).
|
|
110
|
+
|
|
111
|
+
| Not proven | Why |
|
|
112
|
+
|---|---|
|
|
113
|
+
| Payouts that bypass the gate | The gate only protects payouts routed through it; a direct provider API call skips it |
|
|
114
|
+
| Business facts behind an approval | A signature proves who approved, not that the approval was right |
|
|
115
|
+
| Authentic bank data | Statements are imported files, not authenticated feeds |
|
|
116
|
+
| Safety against a stolen signing key | Whoever holds the key can sign valid instructions |
|
|
117
|
+
| Safety against one insider forging both files | Provider export and statement forged together stay consistent |
|
|
118
|
+
| That every event was logged | Integrity, not completeness; that needs an independent witness |
|
|
119
|
+
| That a named model produced an output | A receipt signs the model and output pair you supply |
|
|
120
|
+
|
|
121
|
+
## Two implementations
|
|
122
|
+
|
|
123
|
+
| | Python, `aetherproof/` | Rust, `rust/` |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| Signatures | Ed25519 | Ed25519, plus ML-DSA-65 (FIPS 204) in the Rust core |
|
|
126
|
+
| Secret wiping, constant time compare | no | yes |
|
|
127
|
+
| Distribution | PyPI | source and CI wheels |
|
|
128
|
+
|
|
129
|
+
The Rust core is optional. The Python package does not import it, which CI enforces.
|
|
130
|
+
The 128 byte Rust receipt is a legacy format whose hash fields are 64 bit FNV-1a
|
|
131
|
+
checksums, not cryptographic hashes; see [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md).
|
|
132
|
+
|
|
133
|
+
## Tests
|
|
134
|
+
|
|
135
|
+
Local results on Windows, synthetic data only, not production accuracy:
|
|
136
|
+
|
|
137
|
+
* Python suite, 18 Nov 2026: 900 passed, 0 skipped (`python -m pytest tests/`)
|
|
138
|
+
* Rust core, 18 Nov 2026: 62 passed (`cargo test --release --workspace` in `rust/`)
|
|
139
|
+
* Attack lab, 12 Nov 2026, 100k payouts: 0 of 94,400 clean payouts flagged; forged
|
|
140
|
+
"processed" status caught 500 of 500 with the statement (`python bench/attack_lab.py 100000`)
|
|
141
|
+
* Unknown attack fuzz, 12 Nov 2026: 0 fail open in 60,000 mutated cases
|
|
142
|
+
(`python bench/unknown_attacks.py 60000`)
|
|
143
|
+
|
|
144
|
+
Rerun them before quoting.
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
| | |
|
|
149
|
+
|---|---|
|
|
150
|
+
| [USER_GUIDE.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/USER_GUIDE.md) | install, demo, workflow, file formats |
|
|
151
|
+
| [SIGNED-INSTRUCTION-SPEC.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/SIGNED-INSTRUCTION-SPEC.md) | instruction format, gate, payout checks |
|
|
152
|
+
| [API_CONTRACT.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/API_CONTRACT.md) | local API `/api/v1` |
|
|
153
|
+
| [RECONCILIATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/RECONCILIATION.md) | CloudTrail, checkpoints, RFC 3161 time |
|
|
154
|
+
| [CLAIMS.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/CLAIMS.md) | what this proves and what it does not |
|
|
155
|
+
| [VERIFICATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/VERIFICATION.md) | the offline receipt verifier |
|
|
156
|
+
| [INTEGRATION.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/INTEGRATION.md) | receipt integration paths |
|
|
157
|
+
| [SECURITY.md](https://github.com/pulkit6732/aetherproof/blob/main/SECURITY.md) | reporting a vulnerability, threat model |
|
|
158
|
+
| [ROADMAP.md](https://github.com/pulkit6732/aetherproof/blob/main/docs/ROADMAP.md) | what is planned |
|
|
159
|
+
| [CONTRIBUTING.md](https://github.com/pulkit6732/aetherproof/blob/main/CONTRIBUTING.md) | how to contribute |
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
Apache-2.0. Versions up to 0.2.2 were AGPL-3.0-or-later.
|
|
164
|
+
|
|
165
|
+
Security issues: see [SECURITY.md](https://github.com/pulkit6732/aetherproof/blob/main/SECURITY.md). Please do not open a public issue.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""AetherProof -
|
|
2
|
-
|
|
3
|
-
__version__ = "0.
|
|
4
|
-
__author__ = "Pulkit Srivastava"
|
|
5
|
-
|
|
6
|
-
from aetherproof.core.receipt import Receipt
|
|
7
|
-
from aetherproof.core.signer import Signer
|
|
8
|
-
from aetherproof.core.verifier import Verifier
|
|
9
|
-
from aetherproof.core.log import ReceiptLog
|
|
10
|
-
|
|
11
|
-
__all__ = ["Receipt", "Signer", "Verifier", "ReceiptLog", "__version__"]
|
|
1
|
+
"""AetherProof - proof of authority for payouts and consequential actions."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.5.2"
|
|
4
|
+
__author__ = "Pulkit Srivastava"
|
|
5
|
+
|
|
6
|
+
from aetherproof.core.receipt import Receipt
|
|
7
|
+
from aetherproof.core.signer import Signer
|
|
8
|
+
from aetherproof.core.verifier import Verifier
|
|
9
|
+
from aetherproof.core.log import ReceiptLog
|
|
10
|
+
|
|
11
|
+
__all__ = ["Receipt", "Signer", "Verifier", "ReceiptLog", "__version__"]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""The one contract every layer shares: verdicts, gate decisions, error codes, version.
|
|
2
|
+
|
|
3
|
+
The API, the CLI, the Rune app and any future Rust core use these names and nothing else.
|
|
4
|
+
Changing a meaning here is a contract version bump (see docs/API_CONTRACT.md).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
CONTRACT_VERSION = "1"
|
|
8
|
+
|
|
9
|
+
# Largest amount accepted anywhere, in minor units: 10^15 paise = Rs 10 lakh crore. Far above
|
|
10
|
+
# any single payout, and far below 2^63, so every amount fits the app's 64-bit integers
|
|
11
|
+
# exactly (QA I10/I11/I35: unbounded amounts were signed, and shown as 0 by the app).
|
|
12
|
+
MAX_AMOUNT_MINOR = 10**15
|
|
13
|
+
|
|
14
|
+
# Outcome verdicts (core/payouts.py, core/reconcile.py)
|
|
15
|
+
MATCHED = "matched" # required evidence agrees with the signed authorisation
|
|
16
|
+
CONFLICT = "conflict" # a defined contradiction or hard policy violation is established
|
|
17
|
+
MISSING = "missing" # an expected outcome is absent after its deadline, or it failed/reversed
|
|
18
|
+
AMBIGUOUS = "ambiguous" # evidence incomplete, delayed or not yet decidable; never treated as fraud
|
|
19
|
+
VERDICTS = (MATCHED, CONFLICT, MISSING, AMBIGUOUS)
|
|
20
|
+
|
|
21
|
+
# Gate decisions (core/instruction.py)
|
|
22
|
+
ALLOW = "allow" # authorised, unchanged, inside its window, first use: consumed
|
|
23
|
+
REJECT = "reject" # a hard check failed; not consumed
|
|
24
|
+
REVIEW = "review" # every hard check passed but the payout cannot be tied back to the
|
|
25
|
+
# instruction (no provider reference): a person decides; not consumed
|
|
26
|
+
DECISIONS = (ALLOW, REJECT, REVIEW)
|
|
27
|
+
|
|
28
|
+
# Stable API error codes: clients branch on these, never on message text.
|
|
29
|
+
ERRORS = {
|
|
30
|
+
"invalid_request": 400,
|
|
31
|
+
"missing_field": 400,
|
|
32
|
+
"invalid_amount": 400,
|
|
33
|
+
"invalid_currency": 400,
|
|
34
|
+
"invalid_beneficiary": 400,
|
|
35
|
+
"invalid_window": 400,
|
|
36
|
+
"unknown_source": 400,
|
|
37
|
+
"unreadable_input": 400,
|
|
38
|
+
"unauthenticated": 401,
|
|
39
|
+
"forbidden": 403,
|
|
40
|
+
"bad_host": 403,
|
|
41
|
+
"not_found": 404,
|
|
42
|
+
"unknown_instruction": 404,
|
|
43
|
+
"unknown_run": 404,
|
|
44
|
+
"too_large": 413,
|
|
45
|
+
"rate_limited": 429,
|
|
46
|
+
"locked_out": 429,
|
|
47
|
+
"internal": 500,
|
|
48
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Signed log checkpoints, optionally time stamped by an independent TSA.
|
|
2
|
+
|
|
3
|
+
The hash chain catches edits, reordering and deletions in the middle of the log,
|
|
4
|
+
but not deleting the newest entries: a truncated chain is still a valid chain.
|
|
5
|
+
A checkpoint records (log_size, head_entry_hash) under the log key. Kept
|
|
6
|
+
somewhere the log's operator does not control - sent to the customer, an
|
|
7
|
+
auditor, a witness - it makes truncation and rewriting detectable:
|
|
8
|
+
|
|
9
|
+
log shorter than the checkpoint -> truncated
|
|
10
|
+
entry at log_size has a different hash -> rewritten
|
|
11
|
+
|
|
12
|
+
With a TSA token, the checkpoint also proves every covered receipt existed no
|
|
13
|
+
later than the TSA's genTime, which no longer depends on the signer's clock.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import base64
|
|
17
|
+
import hashlib
|
|
18
|
+
import json
|
|
19
|
+
from dataclasses import dataclass, field, asdict
|
|
20
|
+
from datetime import datetime, timezone
|
|
21
|
+
from typing import Any, Dict, Iterable, List, Optional
|
|
22
|
+
|
|
23
|
+
from .log import ReceiptLog, _as_keyring
|
|
24
|
+
from .receipt import Receipt
|
|
25
|
+
|
|
26
|
+
CHECKPOINT_TYPE = "aetherproof.checkpoint/v1"
|
|
27
|
+
# A signer clock further than this from the TSA's genTime is reported - it is
|
|
28
|
+
# exactly the backdating an independent time source exists to expose.
|
|
29
|
+
MAX_CLOCK_SKEW_MS = 5 * 60 * 1000
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class Checkpoint:
|
|
34
|
+
log_size: int
|
|
35
|
+
head_entry_hash: str
|
|
36
|
+
created_at_ms: int
|
|
37
|
+
signing_key_id: str
|
|
38
|
+
signature: str = ""
|
|
39
|
+
timestamp_token: str = "" # base64 DER RFC 3161 token over digest()
|
|
40
|
+
type: str = CHECKPOINT_TYPE
|
|
41
|
+
|
|
42
|
+
def signing_bytes(self) -> bytes:
|
|
43
|
+
# length-prefixed like Receipt.canonical_message, so fields cannot bleed together
|
|
44
|
+
fields = [self.type, str(self.log_size), self.head_entry_hash,
|
|
45
|
+
str(self.created_at_ms), self.signing_key_id]
|
|
46
|
+
return "".join(f"{len(f)}:{f}" for f in fields).encode("utf-8")
|
|
47
|
+
|
|
48
|
+
def digest(self) -> bytes:
|
|
49
|
+
"""What the TSA time stamps: the signed statement plus its signature."""
|
|
50
|
+
return hashlib.sha256(self.signing_bytes() + bytes.fromhex(self.signature)).digest()
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
return json.dumps(asdict(self), indent=2)
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_json(cls, text: str) -> "Checkpoint":
|
|
57
|
+
data = json.loads(text)
|
|
58
|
+
if data.get("type") != CHECKPOINT_TYPE:
|
|
59
|
+
raise ValueError(f"not an AetherProof checkpoint: type={data.get('type')!r}")
|
|
60
|
+
known = set(cls.__dataclass_fields__)
|
|
61
|
+
return cls(**{k: v for k, v in data.items() if k in known})
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def create_checkpoint(log: ReceiptLog, signer, *, tsa_url: str = "") -> Checkpoint:
|
|
65
|
+
"""Sign the log's current head. With `tsa_url`, also fetch an RFC 3161 token."""
|
|
66
|
+
size = log.max_sequence()
|
|
67
|
+
if size == 0:
|
|
68
|
+
raise ValueError("log is empty; nothing to checkpoint")
|
|
69
|
+
row = log.get_by_sequence(size)
|
|
70
|
+
cp = Checkpoint(
|
|
71
|
+
log_size=size,
|
|
72
|
+
head_entry_hash=row["entry_hash"],
|
|
73
|
+
created_at_ms=int(datetime.now(timezone.utc).timestamp() * 1000),
|
|
74
|
+
signing_key_id=Receipt.key_id(signer.get_public_key()),
|
|
75
|
+
)
|
|
76
|
+
cp.signature = signer.sign(cp.signing_bytes())
|
|
77
|
+
if tsa_url:
|
|
78
|
+
from .timestamp import request_timestamp
|
|
79
|
+
token, _nonce = request_timestamp(tsa_url, cp.digest())
|
|
80
|
+
cp.timestamp_token = base64.b64encode(token).decode("ascii")
|
|
81
|
+
return cp
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclass
|
|
85
|
+
class CheckpointReport:
|
|
86
|
+
ok: bool = False
|
|
87
|
+
problems: List[str] = field(default_factory=list)
|
|
88
|
+
notes: List[str] = field(default_factory=list)
|
|
89
|
+
tsa_time: Optional[str] = None # ISO 8601, only when the token verified
|
|
90
|
+
tsa_subject: str = ""
|
|
91
|
+
|
|
92
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
93
|
+
return asdict(self)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def verify_checkpoint(cp: Checkpoint, log: ReceiptLog, public_keys, *,
|
|
97
|
+
tsa_roots: Iterable = ()) -> CheckpointReport:
|
|
98
|
+
"""Check a checkpoint against the current log.
|
|
99
|
+
|
|
100
|
+
`tsa_roots`: CA certificates trusted for time stamping. If the checkpoint has
|
|
101
|
+
a token and no roots are given, the time is reported as unchecked rather than
|
|
102
|
+
accepted.
|
|
103
|
+
"""
|
|
104
|
+
rep = CheckpointReport()
|
|
105
|
+
key = _as_keyring(public_keys).get(cp.signing_key_id)
|
|
106
|
+
if key is None:
|
|
107
|
+
rep.problems.append(f"no trusted key for signing_key_id={cp.signing_key_id}")
|
|
108
|
+
elif not key.verify(cp.signing_bytes(), cp.signature):
|
|
109
|
+
rep.problems.append("checkpoint signature invalid")
|
|
110
|
+
|
|
111
|
+
have = log.max_sequence()
|
|
112
|
+
if have < cp.log_size:
|
|
113
|
+
rep.problems.append(f"truncated: log has {have} entries, checkpoint recorded {cp.log_size}")
|
|
114
|
+
else:
|
|
115
|
+
row = log.get_by_sequence(cp.log_size)
|
|
116
|
+
if row is None or row["entry_hash"] != cp.head_entry_hash:
|
|
117
|
+
rep.problems.append(f"rewritten: entry {cp.log_size} no longer matches the checkpoint")
|
|
118
|
+
integrity = log.verify_integrity_report()
|
|
119
|
+
if not integrity.ok:
|
|
120
|
+
rep.problems.append(f"log chain broken at {integrity.broken_at}: {integrity.reason}")
|
|
121
|
+
if have > cp.log_size:
|
|
122
|
+
rep.notes.append(f"{have - cp.log_size} entries added after this checkpoint (not covered by it)")
|
|
123
|
+
|
|
124
|
+
if cp.timestamp_token:
|
|
125
|
+
roots = list(tsa_roots)
|
|
126
|
+
if not roots:
|
|
127
|
+
rep.notes.append("time stamp present but not checked: no trusted TSA root given")
|
|
128
|
+
else:
|
|
129
|
+
from .timestamp import TimestampError, verify_token
|
|
130
|
+
try:
|
|
131
|
+
ts = verify_token(base64.b64decode(cp.timestamp_token), cp.digest(), roots)
|
|
132
|
+
rep.tsa_time = ts.gen_time.isoformat()
|
|
133
|
+
rep.tsa_subject = ts.tsa_subject
|
|
134
|
+
skew = abs(ts.gen_time.timestamp() * 1000 - cp.created_at_ms)
|
|
135
|
+
if skew > MAX_CLOCK_SKEW_MS:
|
|
136
|
+
rep.problems.append(f"signer clock differs from TSA time by {skew / 1000:.0f} s")
|
|
137
|
+
except TimestampError as e:
|
|
138
|
+
rep.problems.append(f"time stamp invalid: {e}")
|
|
139
|
+
else:
|
|
140
|
+
rep.notes.append("no independent time stamp; created_at is the signer's own clock")
|
|
141
|
+
|
|
142
|
+
rep.ok = not rep.problems
|
|
143
|
+
return rep
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Evidence package: a stored reconciliation run, sealed so a third party can check it.
|
|
2
|
+
|
|
3
|
+
The package carries the full run (every verdict, reason, signed-instruction summary and the
|
|
4
|
+
hash of every provider and bank record behind it) plus an Ed25519 signature over its
|
|
5
|
+
canonical digest. Anyone holding the originator's public key, obtained separately and not
|
|
6
|
+
from the package, can confirm offline that nothing in it was changed after export.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from typing import Dict, List, Tuple
|
|
11
|
+
|
|
12
|
+
from .hash import sha256
|
|
13
|
+
from .log import _as_keyring
|
|
14
|
+
from .receipt import Receipt
|
|
15
|
+
from .reconcile import canonical_json
|
|
16
|
+
|
|
17
|
+
FORMAT = "aetherproof.evidence/v1"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _digest(run: Dict) -> str:
|
|
21
|
+
return sha256(canonical_json(run))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def export_package(run: Dict, signer) -> Dict:
|
|
25
|
+
digest = _digest(run)
|
|
26
|
+
return {"format": FORMAT, "run": run, "digest": digest,
|
|
27
|
+
"signing_key_id": Receipt.key_id(signer.get_public_key()), "signature": signer.sign(digest.encode())}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def verify_package(pkg: Dict, public_keys) -> Tuple[bool, List[str]]:
|
|
31
|
+
"""(ok, problems). Fails closed: any missing field, unknown key or changed byte is a problem."""
|
|
32
|
+
problems: List[str] = []
|
|
33
|
+
if not isinstance(pkg, dict) or pkg.get("format") != FORMAT:
|
|
34
|
+
return False, [f"not an evidence package (expected format {FORMAT})"]
|
|
35
|
+
run = pkg.get("run")
|
|
36
|
+
if not isinstance(run, dict):
|
|
37
|
+
return False, ["package has no run"]
|
|
38
|
+
if _digest(run) != pkg.get("digest"):
|
|
39
|
+
problems.append("run content does not match the sealed digest: the package was modified after export")
|
|
40
|
+
key = _as_keyring(public_keys).get(pkg.get("signing_key_id"))
|
|
41
|
+
if key is None:
|
|
42
|
+
problems.append(f"no trusted key for signing_key_id={pkg.get('signing_key_id')}")
|
|
43
|
+
elif not key.verify(str(pkg.get("digest", "")).encode(), str(pkg.get("signature", ""))):
|
|
44
|
+
problems.append("signature does not verify under the trusted key")
|
|
45
|
+
return not problems, problems
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def load_package(path) -> Dict:
|
|
49
|
+
with open(path, encoding="utf-8") as f:
|
|
50
|
+
return json.load(f)
|