aetherproof 0.2.1__tar.gz → 0.2.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.
Files changed (39) hide show
  1. {aetherproof-0.2.1/aetherproof.egg-info → aetherproof-0.2.2}/PKG-INFO +142 -3
  2. aetherproof-0.2.2/README.md +317 -0
  3. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/__init__.py +1 -1
  4. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/receipt.py +101 -3
  5. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/ui/display.py +7 -3
  6. {aetherproof-0.2.1 → aetherproof-0.2.2/aetherproof.egg-info}/PKG-INFO +142 -3
  7. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof.egg-info/SOURCES.txt +4 -1
  8. {aetherproof-0.2.1 → aetherproof-0.2.2}/pyproject.toml +1 -1
  9. aetherproof-0.2.2/tests/security/test_cloud_api_attested.py +71 -0
  10. aetherproof-0.2.2/tests/security/test_cloud_models_matrix.py +55 -0
  11. aetherproof-0.2.2/tests/security/test_v12_extensions.py +82 -0
  12. aetherproof-0.2.1/README.md +0 -178
  13. {aetherproof-0.2.1 → aetherproof-0.2.2}/LICENSE +0 -0
  14. {aetherproof-0.2.1 → aetherproof-0.2.2}/MANIFEST.in +0 -0
  15. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/__main__.py +0 -0
  16. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/cli.py +0 -0
  17. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/__init__.py +0 -0
  18. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/hash.py +0 -0
  19. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/keystore.py +0 -0
  20. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/log.py +0 -0
  21. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/signer.py +0 -0
  22. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/core/verifier.py +0 -0
  23. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/ui/__init__.py +0 -0
  24. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/ui/easy_mode.py +0 -0
  25. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/ui/expert_mode.py +0 -0
  26. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof/ui/menus.py +0 -0
  27. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof.egg-info/dependency_links.txt +0 -0
  28. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof.egg-info/entry_points.txt +0 -0
  29. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof.egg-info/requires.txt +0 -0
  30. {aetherproof-0.2.1 → aetherproof-0.2.2}/aetherproof.egg-info/top_level.txt +0 -0
  31. {aetherproof-0.2.1 → aetherproof-0.2.2}/setup.cfg +0 -0
  32. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/conftest.py +0 -0
  33. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/security/README.md +0 -0
  34. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/security/test_cli_contract.py +0 -0
  35. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/security/test_parsing_and_types.py +0 -0
  36. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/security/test_preimage_injectivity.py +0 -0
  37. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/test_log.py +0 -0
  38. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/test_receipt.py +0 -0
  39. {aetherproof-0.2.1 → aetherproof-0.2.2}/tests/test_verifier.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aetherproof
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: AetherProof — the open-source receipt engine. Prototype of Signet.
5
5
  Author: Pulkit Srivastava
6
6
  License: AGPL-3.0-or-later
@@ -46,7 +46,7 @@ Run `aetherproof` with no arguments for the interactive menu:
46
46
 
47
47
  ```
48
48
  .+######+. AETHERPROOF
49
- ## ## v0.2.0
49
+ ## ## v0.2.1
50
50
  # /\ # Cryptographic receipt engine
51
51
  # / \ # Prototype of Signet · R0/L2
52
52
  # / /\ \ #
@@ -64,13 +64,20 @@ Run `aetherproof` with no arguments for the interactive menu:
64
64
  Every time an AI model produces output, AetherProof issues a tamper-proof signed receipt:
65
65
 
66
66
  ```
67
- Receipt ID : receipt_1700000000000
67
+ Receipt ID : ap_8694dae2
68
68
  Model Root : abcdef0123456789... (SHA-256 Merkle of model weights)
69
+ Model Root Type : artifact_hash (bound to the weights) | name_only (claim only)
69
70
  Output Hash : fedcba9876543210... (SHA-256 of the output)
70
71
  Timestamp : 2026-06-11T15:30:00Z
71
72
  Signature : ✓ Ed25519 VALID
72
73
  ```
73
74
 
75
+ The `Model Root Type` field is honest about what the root proves:
76
+ `artifact_hash` (you signed a real weights file), `api_attested` (a cloud API
77
+ returned the model id), or `name_only` (you typed a name). The receipt never
78
+ pretends a name is the weights — see [Local vs Cloud](#local-models-vs-cloud-models)
79
+ below.
80
+
74
81
  **One bit changes → signature fails instantly.**
75
82
 
76
83
  ## Quick start
@@ -102,6 +109,102 @@ aetherproof inspect receipt.json
102
109
  aetherproof tamper receipt.json
103
110
  ```
104
111
 
112
+ ## Local models vs Cloud models
113
+
114
+ This is the most important distinction in AetherProof. **What can be proven
115
+ depends on whether you can see the weights.**
116
+
117
+ | | Local / self-hosted (Llama, custom, on-prem) | Cloud API (GPT-4o, Claude, Grok, DeepSeek, Gemini…) |
118
+ |---|---|---|
119
+ | Who holds the weights | **You** | The provider |
120
+ | Can you hash the weights? | **Yes** | **No — ever** |
121
+ | `model_root_type` | `artifact_hash` | `api_attested` |
122
+ | Proves the exact model ran? | **Yes** | **No** (only the provider can attest that) |
123
+ | Proves input + output unaltered? | Yes | **Yes** |
124
+ | Proves *which model the API claimed* + when? | Yes | **Yes** |
125
+
126
+ ### Why a cloud receipt can't prove the weights — and why that's honest
127
+
128
+ `model_weight_root` requires reading the weights. With GPT-4o or Grok, **the
129
+ weights live on the provider's servers — you never see them, so you cannot hash
130
+ them.** No client-side tool can. Anyone claiming to "cryptographically prove the
131
+ cloud model ran" is overstating it, and a sharp auditor will reject that.
132
+
133
+ What a cloud receipt *does* prove is the part **you are liable for**: the exact
134
+ input your system sent, the exact output it acted on, the model the API *claimed*,
135
+ the time, and that none of it was altered or back-dated. That is your
136
+ record-keeping obligation (SEC 17a-4, FRE 902(14)). The provider owns their
137
+ infrastructure attestation; AetherProof owns the faithfulness of your record.
138
+
139
+ ### How the model name is captured (you don't type it)
140
+
141
+ For `api_attested`, the model identity comes **from the API response**, not from a
142
+ guess. Every major API returns the resolved id:
143
+
144
+ ```python
145
+ # OpenAI / DeepSeek / xAI (Grok) — OpenAI-compatible
146
+ resp = client.chat.completions.create(model="gpt-4o", messages=[...])
147
+ resp.model # "gpt-4o-2024-08-06" ← the RESOLVED id (dated snapshot)
148
+ resp.system_fingerprint # "fp_a7d06e42bc" ← backend config snapshot
149
+ resp.id, resp.created # call id + provider timestamp
150
+
151
+ # Anthropic (Claude)
152
+ resp = client.messages.create(model="claude-opus-4-8", ...)
153
+ resp.model # "claude-opus-4-8"
154
+ ```
155
+
156
+ You asked for `"gpt-4o"`; the API answers `"gpt-4o-2024-08-06"` — the exact
157
+ snapshot that served you. You bind that returned string + `system_fingerprint`,
158
+ so the user can't fake it (it comes back inside the response you're hashing).
159
+
160
+ ### Signing a cloud call
161
+
162
+ ```python
163
+ from aetherproof.core.receipt import Receipt
164
+ from aetherproof.core.keystore import load_or_create_signer
165
+ from aetherproof.core.log import ReceiptLog
166
+
167
+ resp = client.chat.completions.create(model="gpt-4o", messages=[...])
168
+
169
+ r = Receipt.for_api_call(
170
+ provider="openai",
171
+ model_id=resp.model, # read FROM the response
172
+ prompt=user_prompt,
173
+ output_text=resp.choices[0].message.content,
174
+ response_metadata={
175
+ "system_fingerprint": resp.system_fingerprint,
176
+ "response_id": resp.id,
177
+ "created": resp.created,
178
+ },
179
+ )
180
+ # r.model_root_type == "api_attested"
181
+ signer = load_or_create_signer()
182
+ r.signature = signer.sign(r.signing_bytes())
183
+ ReceiptLog().append(r)
184
+ ```
185
+
186
+ This works for **any** OpenAI-compatible or Anthropic-style provider — OpenAI,
187
+ Azure OpenAI, DeepSeek, xAI/Grok, Mistral, Together, Groq, etc. (tested across 17
188
+ model families in `tests/security/test_cloud_models_matrix.py`).
189
+
190
+ ### "But what if they have no provider attestation? Won't they get rejected?"
191
+
192
+ No — the honest answer *passes* the security review. When asked "prove Grok's
193
+ weights ran," the answer is:
194
+
195
+ > "No client-side tool can prove a closed cloud model's weights — only the
196
+ > provider can, and they don't expose it. What we prove is the part you're liable
197
+ > for: the exact input, the exact output, the model the API claimed, the time,
198
+ > and that none of it was altered. That's your record-keeping obligation."
199
+
200
+ In a real dispute (a wrongful denial, a bad summary), the fight is almost never
201
+ "was it GPT-4o or GPT-4-turbo" — it's **"did the AI actually output this, or was
202
+ the record edited afterward?"** AetherProof answers that completely, for any cloud
203
+ model, with zero provider cooperation. The model-identity gap upgrades to a real
204
+ hardware root only when the provider signs their infrastructure (AWS Bedrock +
205
+ Nitro, future) — at which point **Signet** imports that signature and the tier
206
+ graduates `api_attested → hardware-rooted`, with no change to the receipt format.
207
+
105
208
  ## The invariant (what makes this real)
106
209
 
107
210
  ```
@@ -191,6 +294,42 @@ print("output unmodified:", digest == r["output_hash"])
191
294
  That is the whole trust model: **a public key and some SHA-256 + Ed25519 math you
192
295
  can run anywhere, forever.**
193
296
 
297
+ ## Agent-chain context (receipt v1.2)
298
+
299
+ A receipt can optionally commit to **namespaced runtime context** — which agent
300
+ action, run, or policy decision an output belongs to — *inside* the signature.
301
+ This binds a receipt to the exact decision it was issued for, so a valid receipt
302
+ can't be replayed in a different context.
303
+
304
+ ```python
305
+ from aetherproof.core.receipt import Receipt
306
+
307
+ r = Receipt(
308
+ model_weight_root="...",
309
+ output_hash="...",
310
+ signed_extensions={
311
+ "org.liminal.agent_chain/v0.1": {
312
+ "purpose": "generate",
313
+ "actor_id": "agent:planner",
314
+ "run_id": "run_42",
315
+ "policy_decision_id": "pol_7",
316
+ }
317
+ },
318
+ )
319
+ # r.receipt_version is now "1.2"; the SHA-256 commitment over the canonicalized
320
+ # extensions is folded into the signing preimage — tampering any field breaks it.
321
+ ```
322
+
323
+ - **Empty extensions → the receipt stays v1.1, byte-identical.** No impact on
324
+ existing receipts or verifiers.
325
+ - **Non-empty → v1.2.** Per-extension SHA-256 commitments (RFC 8785 JCS
326
+ canonicalization) are aggregated and appended to the injective preimage, so a
327
+ namespace can be disclosed or omitted without breaking the others.
328
+
329
+ This is the AetherProof side of the [agent-chain context spec](https://github.com/pulkit6732/aetherproof/issues/1).
330
+ Multi-hop pipeline aggregation (signing each hop, identifying a tampered hop) is
331
+ **Signet Layer 3** and builds on this primitive.
332
+
194
333
  ## Architecture (god file)
195
334
 
196
335
  AetherProof is **Layer 2** of the **Signet** stack. Signet adds hardware roots, compliance packs, and a transparency network on top.
@@ -0,0 +1,317 @@
1
+ <p align="center">
2
+ <img src="docs/signet-logo.png" alt="Signet" width="240">
3
+ </p>
4
+
5
+ # AetherProof
6
+
7
+ **The open-source receipt engine. Prototype of Signet.**
8
+
9
+ Generate cryptographic receipts that prove an AI output is real and unmodified — no servers, no dependencies, verifiable forever offline.
10
+
11
+ ```
12
+ pip install aetherproof
13
+ ```
14
+
15
+ Run `aetherproof` with no arguments for the interactive menu:
16
+
17
+ ```
18
+ .+######+. AETHERPROOF
19
+ ## ## v0.2.1
20
+ # /\ # Cryptographic receipt engine
21
+ # / \ # Prototype of Signet · R0/L2
22
+ # / /\ \ #
23
+ # / / \ \ # github.com/pulkit6732/aetherproof
24
+ # /______\ \ # Verify(receipt, pk, log) = TRUE
25
+ # \______/ #
26
+ ## ##
27
+ '######'
28
+ ────────────────────────────────────────────────
29
+ Sign · Verify · Inspect · Log · Keygen
30
+ ```
31
+
32
+ ## What it does
33
+
34
+ Every time an AI model produces output, AetherProof issues a tamper-proof signed receipt:
35
+
36
+ ```
37
+ Receipt ID : ap_8694dae2
38
+ Model Root : abcdef0123456789... (SHA-256 Merkle of model weights)
39
+ Model Root Type : artifact_hash (bound to the weights) | name_only (claim only)
40
+ Output Hash : fedcba9876543210... (SHA-256 of the output)
41
+ Timestamp : 2026-06-11T15:30:00Z
42
+ Signature : ✓ Ed25519 VALID
43
+ ```
44
+
45
+ The `Model Root Type` field is honest about what the root proves:
46
+ `artifact_hash` (you signed a real weights file), `api_attested` (a cloud API
47
+ returned the model id), or `name_only` (you typed a name). The receipt never
48
+ pretends a name is the weights — see [Local vs Cloud](#local-models-vs-cloud-models)
49
+ below.
50
+
51
+ **One bit changes → signature fails instantly.**
52
+
53
+ ## Quick start
54
+
55
+ ### Easy mode (for anyone)
56
+
57
+ ```bash
58
+ aetherproof
59
+ ```
60
+
61
+ Step-by-step wizard:
62
+ 1. What model did you use?
63
+ 2. Paste the output
64
+ 3. Receipt is signed and saved
65
+
66
+ ### Expert mode (for developers)
67
+
68
+ ```bash
69
+ # Generate a receipt
70
+ aetherproof sign model.onnx output.txt
71
+
72
+ # Verify it (offline, forever)
73
+ aetherproof verify receipt.json
74
+
75
+ # Inspect all fields
76
+ aetherproof inspect receipt.json
77
+
78
+ # Test tamper detection
79
+ aetherproof tamper receipt.json
80
+ ```
81
+
82
+ ## Local models vs Cloud models
83
+
84
+ This is the most important distinction in AetherProof. **What can be proven
85
+ depends on whether you can see the weights.**
86
+
87
+ | | Local / self-hosted (Llama, custom, on-prem) | Cloud API (GPT-4o, Claude, Grok, DeepSeek, Gemini…) |
88
+ |---|---|---|
89
+ | Who holds the weights | **You** | The provider |
90
+ | Can you hash the weights? | **Yes** | **No — ever** |
91
+ | `model_root_type` | `artifact_hash` | `api_attested` |
92
+ | Proves the exact model ran? | **Yes** | **No** (only the provider can attest that) |
93
+ | Proves input + output unaltered? | Yes | **Yes** |
94
+ | Proves *which model the API claimed* + when? | Yes | **Yes** |
95
+
96
+ ### Why a cloud receipt can't prove the weights — and why that's honest
97
+
98
+ `model_weight_root` requires reading the weights. With GPT-4o or Grok, **the
99
+ weights live on the provider's servers — you never see them, so you cannot hash
100
+ them.** No client-side tool can. Anyone claiming to "cryptographically prove the
101
+ cloud model ran" is overstating it, and a sharp auditor will reject that.
102
+
103
+ What a cloud receipt *does* prove is the part **you are liable for**: the exact
104
+ input your system sent, the exact output it acted on, the model the API *claimed*,
105
+ the time, and that none of it was altered or back-dated. That is your
106
+ record-keeping obligation (SEC 17a-4, FRE 902(14)). The provider owns their
107
+ infrastructure attestation; AetherProof owns the faithfulness of your record.
108
+
109
+ ### How the model name is captured (you don't type it)
110
+
111
+ For `api_attested`, the model identity comes **from the API response**, not from a
112
+ guess. Every major API returns the resolved id:
113
+
114
+ ```python
115
+ # OpenAI / DeepSeek / xAI (Grok) — OpenAI-compatible
116
+ resp = client.chat.completions.create(model="gpt-4o", messages=[...])
117
+ resp.model # "gpt-4o-2024-08-06" ← the RESOLVED id (dated snapshot)
118
+ resp.system_fingerprint # "fp_a7d06e42bc" ← backend config snapshot
119
+ resp.id, resp.created # call id + provider timestamp
120
+
121
+ # Anthropic (Claude)
122
+ resp = client.messages.create(model="claude-opus-4-8", ...)
123
+ resp.model # "claude-opus-4-8"
124
+ ```
125
+
126
+ You asked for `"gpt-4o"`; the API answers `"gpt-4o-2024-08-06"` — the exact
127
+ snapshot that served you. You bind that returned string + `system_fingerprint`,
128
+ so the user can't fake it (it comes back inside the response you're hashing).
129
+
130
+ ### Signing a cloud call
131
+
132
+ ```python
133
+ from aetherproof.core.receipt import Receipt
134
+ from aetherproof.core.keystore import load_or_create_signer
135
+ from aetherproof.core.log import ReceiptLog
136
+
137
+ resp = client.chat.completions.create(model="gpt-4o", messages=[...])
138
+
139
+ r = Receipt.for_api_call(
140
+ provider="openai",
141
+ model_id=resp.model, # read FROM the response
142
+ prompt=user_prompt,
143
+ output_text=resp.choices[0].message.content,
144
+ response_metadata={
145
+ "system_fingerprint": resp.system_fingerprint,
146
+ "response_id": resp.id,
147
+ "created": resp.created,
148
+ },
149
+ )
150
+ # r.model_root_type == "api_attested"
151
+ signer = load_or_create_signer()
152
+ r.signature = signer.sign(r.signing_bytes())
153
+ ReceiptLog().append(r)
154
+ ```
155
+
156
+ This works for **any** OpenAI-compatible or Anthropic-style provider — OpenAI,
157
+ Azure OpenAI, DeepSeek, xAI/Grok, Mistral, Together, Groq, etc. (tested across 17
158
+ model families in `tests/security/test_cloud_models_matrix.py`).
159
+
160
+ ### "But what if they have no provider attestation? Won't they get rejected?"
161
+
162
+ No — the honest answer *passes* the security review. When asked "prove Grok's
163
+ weights ran," the answer is:
164
+
165
+ > "No client-side tool can prove a closed cloud model's weights — only the
166
+ > provider can, and they don't expose it. What we prove is the part you're liable
167
+ > for: the exact input, the exact output, the model the API claimed, the time,
168
+ > and that none of it was altered. That's your record-keeping obligation."
169
+
170
+ In a real dispute (a wrongful denial, a bad summary), the fight is almost never
171
+ "was it GPT-4o or GPT-4-turbo" — it's **"did the AI actually output this, or was
172
+ the record edited afterward?"** AetherProof answers that completely, for any cloud
173
+ model, with zero provider cooperation. The model-identity gap upgrades to a real
174
+ hardware root only when the provider signs their infrastructure (AWS Bedrock +
175
+ Nitro, future) — at which point **Signet** imports that signature and the tier
176
+ graduates `api_attested → hardware-rooted`, with no change to the receipt format.
177
+
178
+ ## The invariant (what makes this real)
179
+
180
+ ```
181
+ Verify(receipt, public_key, log) = TRUE
182
+
183
+ using ONLY those three inputs, forever, with zero dependency on
184
+ AetherProof servers, any vendor SDK, or any hardware driver.
185
+ ```
186
+
187
+ This is not a claim. It's built in. Offline verification uses only:
188
+ 1. The receipt file
189
+ 2. The public key (PEM file)
190
+ 3. (Optional) transparency log entry
191
+
192
+ No network. No API calls. No special hardware. Works in 2026, 2035, 2050.
193
+
194
+ ## How offline verification actually works
195
+
196
+ You can prove a receipt is genuine with **no internet and no AetherProof code at
197
+ all** — the math is open. Here is the exact process.
198
+
199
+ ### What you need (the three inputs)
200
+ 1. **The receipt** (`ap_xxxx.json`) — the signed claim.
201
+ 2. **The public key** (`ap_xxxx.pub`, a PEM file) — shipped beside the receipt.
202
+ 3. **(Optional) the original output file** — only if you also want to prove the
203
+ output itself wasn't changed.
204
+
205
+ ### The steps
206
+ 1. **Rebuild the signed message.** The receipt is signed over a canonical,
207
+ length-prefixed preimage of its fields (version, model root, model-root-type,
208
+ input commitment, output hash, timestamp, log sequence, hardware evidence, log
209
+ anchor). The encoding is injective, so no two distinct receipts can share a
210
+ preimage (and thus a signature).
211
+ 2. **Check the Ed25519 signature** of that preimage against the public key. If it
212
+ verifies, the receipt's contents are exactly what was signed — a single
213
+ changed bit fails this check.
214
+ 3. **(Optional) Re-hash the output file** with SHA-256 (raw bytes, streamed) and
215
+ compare to the receipt's `output_hash`. If they match, the output is unchanged.
216
+
217
+ ### The one-command way
218
+
219
+ ```bash
220
+ # signature only
221
+ aetherproof verify ap_xxxx.json
222
+
223
+ # signature + confirm the output file still matches
224
+ aetherproof verify ap_xxxx.json --output original_output.txt
225
+
226
+ # scripting / CI: machine-readable, exits non-zero on any failure
227
+ aetherproof verify ap_xxxx.json --output original_output.txt --quiet
228
+ # -> {"valid": true, "signature_valid": true, "output_unmodified": true}
229
+ ```
230
+
231
+ Exit code is `0` only when everything checks out, `1` on any tampering — so
232
+ `aetherproof verify … && deploy` is safe in a pipeline.
233
+
234
+ ### Verify without AetherProof (any Ed25519 library)
235
+
236
+ Because the format is open, anyone can verify with a standard crypto library —
237
+ no dependency on this tool. In Python with `cryptography`:
238
+
239
+ ```python
240
+ import json, hashlib
241
+ from cryptography.hazmat.primitives.serialization import load_pem_public_key
242
+
243
+ r = json.load(open("ap_xxxx.json"))
244
+ pub = load_pem_public_key(open("ap_xxxx.pub", "rb").read())
245
+
246
+ # rebuild the injective preimage: "<len>:<field>" for each field, in order
247
+ fields = [
248
+ r["receipt_version"], r["model_weight_root"], r["model_root_type"],
249
+ r["input_commitment"], r["output_hash"], str(r["timestamp_ms"]),
250
+ str(r["log_sequence"]),
251
+ json.dumps(r["hw_evidence"], sort_keys=True, separators=(",", ":")),
252
+ r["log_anchor"],
253
+ ]
254
+ preimage = "".join(f"{len(f)}:{f}" for f in fields).encode("utf-8")
255
+
256
+ pub.verify(bytes.fromhex(r["signature"]), preimage) # raises if invalid
257
+ print("signature OK")
258
+
259
+ # optional: prove the output file is unchanged
260
+ digest = hashlib.sha256(open("original_output.txt", "rb").read()).hexdigest()
261
+ print("output unmodified:", digest == r["output_hash"])
262
+ ```
263
+
264
+ That is the whole trust model: **a public key and some SHA-256 + Ed25519 math you
265
+ can run anywhere, forever.**
266
+
267
+ ## Agent-chain context (receipt v1.2)
268
+
269
+ A receipt can optionally commit to **namespaced runtime context** — which agent
270
+ action, run, or policy decision an output belongs to — *inside* the signature.
271
+ This binds a receipt to the exact decision it was issued for, so a valid receipt
272
+ can't be replayed in a different context.
273
+
274
+ ```python
275
+ from aetherproof.core.receipt import Receipt
276
+
277
+ r = Receipt(
278
+ model_weight_root="...",
279
+ output_hash="...",
280
+ signed_extensions={
281
+ "org.liminal.agent_chain/v0.1": {
282
+ "purpose": "generate",
283
+ "actor_id": "agent:planner",
284
+ "run_id": "run_42",
285
+ "policy_decision_id": "pol_7",
286
+ }
287
+ },
288
+ )
289
+ # r.receipt_version is now "1.2"; the SHA-256 commitment over the canonicalized
290
+ # extensions is folded into the signing preimage — tampering any field breaks it.
291
+ ```
292
+
293
+ - **Empty extensions → the receipt stays v1.1, byte-identical.** No impact on
294
+ existing receipts or verifiers.
295
+ - **Non-empty → v1.2.** Per-extension SHA-256 commitments (RFC 8785 JCS
296
+ canonicalization) are aggregated and appended to the injective preimage, so a
297
+ namespace can be disclosed or omitted without breaking the others.
298
+
299
+ This is the AetherProof side of the [agent-chain context spec](https://github.com/pulkit6732/aetherproof/issues/1).
300
+ Multi-hop pipeline aggregation (signing each hop, identifying a tampered hop) is
301
+ **Signet Layer 3** and builds on this primitive.
302
+
303
+ ## Architecture (god file)
304
+
305
+ AetherProof is **Layer 2** of the **Signet** stack. Signet adds hardware roots, compliance packs, and a transparency network on top.
306
+
307
+ ## License
308
+
309
+ AGPL-3.0-or-later. Use it, deploy it, fork it, verify it — but if you run a
310
+ modified version as a network service, you must release your changes under the
311
+ same license. (Need a permissive/commercial license? That's what Signet is for.)
312
+
313
+ ---
314
+
315
+ **AetherProof is what you get when you need tamper-proof proof.**
316
+
317
+ **Signet is what you get when you need hardware roots, compliance packs, and a transparency log.**
@@ -1,6 +1,6 @@
1
1
  """AetherProof — the open-source receipt engine. Prototype of Signet."""
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.2"
4
4
  __author__ = "Pulkit Srivastava"
5
5
 
6
6
  from aetherproof.core.receipt import Receipt
@@ -17,9 +17,13 @@ class Receipt:
17
17
  receipt_version: str = "1.1" # 1.1 = injective length-prefixed preimage
18
18
  model_weight_root: str = "" # SHA-256 Merkle root of model weights
19
19
  model_root_type: str = "name_only" # what model_weight_root actually is:
20
- # "artifact_hash" = SHA-256 of a real weights file/dir (binds to the weights)
21
- # "name_only" = SHA-256 of a model-name string only (proves the CLAIM of
22
- # that name at that time; does NOT prove the weights)
20
+ # "artifact_hash" = SHA-256 of a real weights file/dir (binds the weights)
21
+ # "api_attested" = SHA-256 over the model id + provider metadata that the
22
+ # CLOUD API RETURNED (gpt-4o-2024-08-06, system_fingerprint).
23
+ # Proves input+output+claimed-model, NOT the weights — only
24
+ # the provider can attest those. Honest cloud tier.
25
+ # "name_only" = SHA-256 of a hand-typed model-name string only (proves the
26
+ # CLAIM of that name; weakest — the user could type anything)
23
27
  input_commitment: str = "" # SHA-256 of input prompt (may be hidden)
24
28
  output_hash: str = "" # SHA-256 of model output
25
29
  timestamp_ms: int = 0 # Unix milliseconds
@@ -28,6 +32,12 @@ class Receipt:
28
32
  signature: str = "" # Ed25519 (AetherProof) or Ed25519+ML-DSA-65 (Signet)
29
33
  log_anchor: str = "" # "local://log/<log_sequence>" for open-source version
30
34
  receipt_id: str = "" # Unique identifier (timestamp-based)
35
+ # Namespaced signed extensions (e.g. agent-chain causal context, issue #1).
36
+ # Each key is a namespace (e.g. "org.liminal.agent_chain/v0.1") mapping to a
37
+ # JSON object. When non-empty, a SHA-256 commitment over the canonicalized
38
+ # extensions is appended to the signing preimage and the receipt is v1.2.
39
+ # When empty, the receipt is byte-for-byte a v1.1 receipt (backward compatible).
40
+ signed_extensions: Dict[str, Any] = field(default_factory=dict)
31
41
 
32
42
  def __post_init__(self):
33
43
  """Set receipt_id if not provided."""
@@ -35,6 +45,10 @@ class Receipt:
35
45
  self.receipt_id = f"receipt_{self.timestamp_ms}"
36
46
  if not self.timestamp_ms:
37
47
  self.timestamp_ms = int(datetime.now().timestamp() * 1000)
48
+ # v1.2 only when extensions are present; otherwise stay v1.1 so existing
49
+ # receipts and verifiers are unaffected.
50
+ if self.signed_extensions and self.receipt_version == "1.1":
51
+ self.receipt_version = "1.2"
38
52
 
39
53
  def to_dict(self) -> Dict[str, Any]:
40
54
  """Export as dictionary."""
@@ -65,6 +79,11 @@ class Receipt:
65
79
  self._canonical_hw_evidence(),
66
80
  self.log_anchor,
67
81
  ]
82
+ # v1.2: append the extensions commitment as one more length-prefixed
83
+ # field. The injective encoding makes this unambiguous; a v1.1 receipt
84
+ # never has this field, so the two can never collide.
85
+ if self.signed_extensions:
86
+ fields.append(self.signed_extensions_hash())
68
87
  return "".join(f"{len(f)}:{f}" for f in fields)
69
88
 
70
89
  def _canonical_hw_evidence(self) -> str:
@@ -73,6 +92,35 @@ class Receipt:
73
92
  # objects for Signet R1+.
74
93
  return json.dumps(self.hw_evidence, sort_keys=True, separators=(",", ":"))
75
94
 
95
+ @staticmethod
96
+ def _canonicalize(obj: Any) -> bytes:
97
+ # RFC 8785 JCS-equivalent for the string-valued extension objects this
98
+ # format uses: sorted keys, no insignificant whitespace, UTF-8. (Full
99
+ # RFC 8785 number formatting is not exercised because every extension
100
+ # field is a string id / ref / enum, never a float.)
101
+ return json.dumps(
102
+ obj, sort_keys=True, separators=(",", ":"), ensure_ascii=False
103
+ ).encode("utf-8")
104
+
105
+ def signed_extensions_hash(self) -> str:
106
+ """Aggregated commitment over the signed extensions.
107
+
108
+ Per-extension commitments (sha256 of each namespace's canonical bytes),
109
+ sorted, then hashed together. Per-extension (not whole-map) so a holder
110
+ can disclose or omit one namespace without breaking the others — the same
111
+ selective-disclosure property the base receipt respects. With a single
112
+ extension the two collapse to identical bytes, so this is forward-safe.
113
+ """
114
+ import hashlib
115
+
116
+ per = []
117
+ for ns in sorted(self.signed_extensions):
118
+ body = self._canonicalize(self.signed_extensions[ns])
119
+ leaf = hashlib.sha256(self._canonicalize(ns) + body).hexdigest()
120
+ per.append(leaf)
121
+ agg = hashlib.sha256("".join(per).encode("utf-8")).hexdigest()
122
+ return f"sha256:{agg}"
123
+
76
124
  def signing_bytes(self) -> bytes:
77
125
  return self.canonical_message().encode("utf-8")
78
126
 
@@ -91,6 +139,56 @@ class Receipt:
91
139
  "la": self.log_anchor,
92
140
  }
93
141
 
142
+ @staticmethod
143
+ def api_attested_root(model_id: str, provider: str = "", **metadata: Any) -> str:
144
+ """Build a model root from what a CLOUD API RETURNED — never from a
145
+ hand-typed name.
146
+
147
+ `model_id` is the resolved id the API echoed back (e.g.
148
+ "gpt-4o-2024-08-06"), `provider` is "openai"/"anthropic"/"xai"/..., and
149
+ metadata holds provider fields that pin the backend
150
+ (system_fingerprint, response id, created). The order is fixed and the
151
+ keys sorted so the same response always yields the same root.
152
+ """
153
+ import hashlib
154
+
155
+ parts = [f"api:{provider}", f"model:{model_id}"]
156
+ for k in sorted(metadata):
157
+ if metadata[k] is not None:
158
+ parts.append(f"{k}:{metadata[k]}")
159
+ return hashlib.sha256("|".join(parts).encode("utf-8")).hexdigest()
160
+
161
+ @classmethod
162
+ def for_api_call(
163
+ cls,
164
+ *,
165
+ provider: str,
166
+ model_id: str,
167
+ prompt: str,
168
+ output_text: str,
169
+ response_metadata: Dict[str, Any] = None,
170
+ log_sequence: int = 0,
171
+ log_anchor: str = "",
172
+ ) -> "Receipt":
173
+ """Construct an honest cloud-API receipt (model_root_type='api_attested').
174
+
175
+ The model identity comes from `model_id` — which the caller reads off the
176
+ API RESPONSE (resp.model), not from a guess. Binds: input commitment,
177
+ output hash, and the provider-reported model + metadata. Does NOT prove
178
+ the weights ran (only the provider can attest that).
179
+ """
180
+ from .hash import hash_output
181
+
182
+ meta = response_metadata or {}
183
+ return cls(
184
+ model_weight_root=cls.api_attested_root(model_id, provider, **meta),
185
+ model_root_type="api_attested",
186
+ input_commitment=hash_output(prompt),
187
+ output_hash=hash_output(output_text),
188
+ log_sequence=log_sequence,
189
+ log_anchor=log_anchor,
190
+ )
191
+
94
192
  @classmethod
95
193
  def from_dict(cls, data: Dict[str, Any]) -> "Receipt":
96
194
  """Reconstruct from dictionary, coercing numeric fields to int.
@@ -10,6 +10,10 @@ from rich.text import Text
10
10
  from typing import Dict, Any
11
11
  from datetime import datetime
12
12
 
13
+ from aetherproof import __version__
14
+
15
+ _V = f"v{__version__}" # single source of truth — never hardcode the version
16
+
13
17
  # force utf-8 so box-drawing / · / ✓ encode under any Windows codepage
14
18
  for _stream in (sys.stdout, sys.stderr):
15
19
  try:
@@ -36,7 +40,7 @@ _LOGO_MARK = r""" .+######+.
36
40
 
37
41
  _LOGO_LINES = [
38
42
  ("AETHERPROOF", f"bold {BRAND}"),
39
- ("v0.2.0", "dim white"),
43
+ (_V, "dim white"),
40
44
  ("Cryptographic receipt engine", "white"),
41
45
  ("Prototype of Signet · R0/L2", "dim"),
42
46
  ("", None),
@@ -89,7 +93,7 @@ def run_about() -> None:
89
93
  Text(""),
90
94
  invariant,
91
95
  Text(""),
92
- Text("Version: v0.2.0"),
96
+ Text(f"Version: {_V}"),
93
97
  Text("GitHub: github.com/pulkit6732/aetherproof"),
94
98
  )
95
99
  console.print(Panel(body, title="About AetherProof", border_style="dim"))
@@ -101,7 +105,7 @@ def header() -> None:
101
105
  subtitle = Text("the open-source receipt engine", style="dim cyan")
102
106
  console.print(f"\n{title_text}")
103
107
  console.print(subtitle)
104
- console.print("Prototype of Signet • v0.2.0\n", style="dim")
108
+ console.print(f"Prototype of Signet • {_V}\n", style="dim")
105
109
 
106
110
 
107
111
  def receipt_table(receipt: "Receipt") -> None: