avm-ac2 0.1.0__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.
avm_ac2-0.1.0/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 AlgoVoi
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,19 @@
1
+ # The sdist must be able to run the tests it ships. Without these rules the
2
+ # archive contained test_*.py but NOT the fixtures they read, so an extracted-sdist
3
+ # run skipped every capture test -- while the repo gate passed, because it tests a
4
+ # Git checkout. Same defect class avm-mesh's MANIFEST.in records; found here by
5
+ # inspecting the sdist rather than by trusting the wheel build.
6
+ include LICENSE NOTICE README.md
7
+ recursive-include src *.py
8
+ recursive-include tests *.py *.json *.json.gz *.mjs
9
+ recursive-include examples *.py *.json
10
+ recursive-include tools *.py *.sh
11
+
12
+ # Captures are pinned by SHA-256 in tests/test_consent.py and the interop fixture
13
+ # holds a signature; both must travel byte-exact. A sdist is a tar of files, so it
14
+ # does not normalise line endings itself -- but .gitattributes has no effect once
15
+ # the archive is extracted, hence the explicit -text rules on the tracked files.
16
+ include tests/captures/proofpack-66457600.json
17
+ include tests/captures/voi-proofpack-24213754.json.gz
18
+ include tests/interop/ac2_interop.json
19
+ include tests/interop/interop_emit.mjs
avm_ac2-0.1.0/NOTICE ADDED
@@ -0,0 +1,26 @@
1
+ avm-mesh
2
+ Copyright 2026 AlgoVoi
3
+
4
+ This software was created and is maintained by AlgoVoi, and is offered as a
5
+ gift to the Algorand and Voi communities under the Apache License, Version 2.0.
6
+
7
+ You are free to use, modify, and redistribute it. If you redistribute this
8
+ software or a derivative of it, this NOTICE and the attribution to AlgoVoi
9
+ must be retained (Apache-2.0, Section 4).
10
+
11
+ avm-ac2 implements a binding between two independently published protocols and
12
+ claims nothing over either:
13
+
14
+ * AC2 (Agentic Communication and Control), a Draft specification published by
15
+ the Algorand Foundation at https://github.com/algorandfoundation/ac2. This
16
+ package does not redistribute AC2 code: the `@algorandfoundation/ac2-sdk`
17
+ npm package (Apache-2.0) is used from the JavaScript side and is not bundled
18
+ here.
19
+
20
+ * avm-mesh, by AlgoVoi (Apache-2.0), which supplies the sealed settlement
21
+ receipt format and the canonicalising function this package imports rather
22
+ than duplicating.
23
+
24
+ "Algorand", "AC2" and "Voi" are the names and marks of their respective owners.
25
+ Use of the name "AC2" here describes the protocol implemented and implies no
26
+ endorsement by, or affiliation with, the Algorand Foundation.
avm_ac2-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.4
2
+ Name: avm-ac2
3
+ Version: 0.1.0
4
+ Summary: AC2 consent bound to an avm-mesh settlement: proof of who authorised a transaction, on Algorand and Voi
5
+ Author-email: AlgoVoi <chopmob@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/chopmob-cloud/avm-ac2
8
+ Project-URL: Repository, https://github.com/chopmob-cloud/avm-ac2
9
+ Project-URL: Issues, https://github.com/chopmob-cloud/avm-ac2
10
+ Keywords: algorand,voi,avm,ac2,consent,settlement,state-proof,agents
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Security :: Cryptography
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: NOTICE
22
+ Requires-Dist: avm-mesh>=0.13.5
23
+ Requires-Dist: cryptography>=42
24
+ Dynamic: license-file
25
+
26
+ # avm-ac2
27
+
28
+ **Proof of who authorised a settlement, bound to proof that it settled** — on
29
+ Algorand and Voi, verifiable offline.
30
+
31
+ An `avm-mesh` receipt proves *what settled*: a transaction was final, and what it
32
+ did, anchored in the chain's own consensus. It says nothing about *who authorised
33
+ it*. [AC2](https://github.com/algorandfoundation/ac2) (the Algorand Foundation's
34
+ Agentic Communication and Control protocol) is the other half — a consent and
35
+ signing-delegation channel where an agent asks a controller's wallet to sign a
36
+ payload and gets a signature back, never the key.
37
+
38
+ `avm-ac2` joins them. Neither protocol is modified: the consent travels inside the
39
+ sealed receipt's existing `content` dict, which `avm_mesh.sealed.seal` hashes
40
+ *before* inserting the consensus attestation, so the block is covered by
41
+ `content_hash` and cannot be edited, swapped or stripped without breaking LEVEL 1.
42
+
43
+ ## What it proves — and what it refuses to claim
44
+
45
+ An AC2 `SigningResponse` body carries exactly `signature`, `public_key`,
46
+ `address` and `key_type`. There is **no WebAuthn material in it** — no
47
+ `authenticatorData`, no `clientDataJSON`, no `credentialId`, no attestation
48
+ object. The Draft spec's Pattern 2 diagram mentions constraints "expiry, scope",
49
+ but no normative field carries either.
50
+
51
+ **So a third party holding only an AC2 response cannot tell a hardware passkey
52
+ from a software key.** The spec's design goal is that the *wallet* requires user
53
+ verification; that is a claim about the wallet's behaviour, and the message does
54
+ not let a verifier re-check it.
55
+
56
+ This package therefore never says "hardware-bound" and never says "a human
57
+ approved". It reports one of four levels, and returns the reason alongside it:
58
+
59
+ | Level | Established | **Not** established |
60
+ |---|---|---|
61
+ | `none` | no consent block present | — |
62
+ | `consent_present` | the holder of `public_key` signed **this** settlement's canonical payload | that a human, or a passkey, was involved |
63
+ | `sender_bound` | that key **is** the authenticated transaction sender | still not a passkey — only that the payer signed |
64
+ | `consensus_bound` | additionally the settlement reached `stake_attested` | that goods shipped |
65
+
66
+ `sender_bound` is the property worth having: it collapses "someone approved this"
67
+ and "this was paid" into one key, so the approval and the payment cannot be
68
+ substituted for each other, and the payer cannot be misrepresented.
69
+
70
+ ## Why the payer is the signer, not the agent
71
+
72
+ AC2's whole design is that the agent cannot sign. In an x402 flow the agent holds
73
+ a *delegated* signature and submits it; the account that funds the transaction is
74
+ the controller's. AC2's `address` field — the Algorand account bound to the
75
+ passkey by the Liquid Extension — is therefore the natural payer, and
76
+ `address == sender` is the binding to check. A wallet that signs from a different
77
+ account than it advertised fails, which is intended: the alternative is trusting
78
+ the agent's word about who paid whom.
79
+
80
+ ## Install
81
+
82
+ ```bash
83
+ pip install avm-ac2
84
+ ```
85
+
86
+ `avm-ac2` 0.1.0 is on PyPI. Installing from the repository still works and tracks
87
+ `main` rather than the release:
88
+
89
+ ```bash
90
+ pip install "git+https://github.com/chopmob-cloud/avm-ac2@main"
91
+ ```
92
+
93
+ `avm-mesh` supplies the sealed-receipt format and its canonicaliser, so this
94
+ package extends it rather than duplicating either. `cryptography` is a direct
95
+ dependency (not an extra): every caller here verifies an Ed25519 signature, so
96
+ there is no dependency-light path to protect.
97
+
98
+ ## Use
99
+
100
+ ```python
101
+ import base64
102
+ from avm_ac2 import build_consent, consent_level, consent_payload, sender_from_bundle
103
+ from avm_mesh import sealed
104
+
105
+ settlement = {"chain": report.genesis_id, "txid": report.txid,
106
+ "round": report.round, "amount": "0", "asset": 586896}
107
+
108
+ # 1. Ask the controller to sign consent_payload(settlement) over AC2, then build
109
+ # the block from the SigningResponse. The agent never holds the key.
110
+ consent = build_consent(
111
+ did=resp.from_did, sig_hint="raw-ed25519",
112
+ public_key_b64=resp.body.public_key, signature_b64=resp.body.signature,
113
+ settlement=settlement,
114
+ )
115
+
116
+ # 2. Seal it: the consent lands inside the bytes content_hash covers.
117
+ envelope = sealed.seal(
118
+ {"version": 1, "settlement": settlement, "ac2_consent": consent},
119
+ bundle, evidence_uri, trusted_voters=anchor,
120
+ )
121
+
122
+ # 3. Anyone verifies, with the sender re-derived from the authenticated STIB.
123
+ out = consent_level(envelope, report, bundle=bundle)
124
+ print(out["level"], out["reason"])
125
+ ```
126
+
127
+ ### Command line
128
+
129
+ ```bash
130
+ avm-ac2 payload settlement.json # exact bytes to be signed
131
+ avm-ac2 verify receipt.json --evidence ./bundles --genesis "$GENESIS" \
132
+ --voters-commitment "$VC" --ln-proven-weight N
133
+ avm-ac2 level receipt.json --min-level sender_bound # exits 2 if below
134
+ ```
135
+
136
+ ### Validation
137
+
138
+ #### Clean-room validation (this package, standalone)
139
+
140
+ Run in a fresh `python:3.12-slim` container, installing with `--no-index` from a local wheel set so
141
+ nothing is fetched, against the **installed wheels** rather than the source tree:
142
+
143
+ | Stage | Result |
144
+ |---|---|
145
+ | Artefacts and captures staged | PASS |
146
+ | Offline install from wheels only (`avm-ac2` → `avm-mesh` → `avm-proofpack` → `avm-effectproof`) | PASS |
147
+ | Installed version matches `pyproject.toml` (`0.1.0`) | PASS |
148
+ | Both packages import from `site-packages`, not `/work/src` | PASS |
149
+ | Suite | **44 tests, 0 skipped, 0 failed** |
150
+ | Shipped example drives both chains on the installed wheel | **PASS** |
151
+ | `avm-ac2` entry point runs; `payload` emits canonical bytes | PASS |
152
+ | **CLEAN-ROOM GREEN** | 9 PASS, 0 FAIL across 5 stages |
153
+
154
+ #### Mutation check (inside that same container)
155
+
156
+ Removing the sender comparison from the *installed* `consent.py` in `site-packages` turned the suite red:
157
+
158
+ ```
159
+ FAILED test_a_consent_from_a_foreign_key_is_refused_on_both_chains[algorand]
160
+ FAILED test_a_consent_from_a_foreign_key_is_refused_on_both_chains[voi]
161
+ 2 failed, 14 passed
162
+ ```
163
+
164
+ Restoring the file returned it to `20 passed`. The guard is load-bearing, not merely present.
165
+
166
+ #### Local, on both chains
167
+
168
+ `tests/test_consent.py` — **20 passed** on Python 3.12, driving the shipped
169
+ `avm_mesh.sealed.seal` and the real captures:
170
+
171
+ | Chain | Capture | Genesis pin | Tier reached | Sender read from STIB |
172
+ |---|---|---|---|---|
173
+ | Algorand mainnet | `avm-mesh/examples/proofpack-66457600.json` | `wGHE2Pwdv…` | `stake_attested` | `Q34SYPNGP7CW77LIAYNNUZV7Q6GRSUJVKMIAPOJFG3TZULNJGPRA` |
174
+ | Voi mainnet | `avm-mesh/examples/voi-proofpack-24213754.json.gz` | `r20fSQI8g…` | `stake_attested` | `3S6DAF3YX3RDIS4FV2QIPIKGHAPZ52OPOTR6NR25O7RYHTYMBSDQ` |
175
+
176
+ Both captures ship in [`tests/captures/`](tests/captures) and are pinned by SHA-256, so this suite runs
177
+ from a fresh clone with no sibling checkout. The Voi digest is the same one `avm-mesh`'s own
178
+ `test_voi_chain.py` pins, so the two suites agree on the artefact. They are marked `-text` in
179
+ `.gitattributes`, because a checkout that normalises the bytes breaks a hash assertion on one platform
180
+ only. Per chain the tests cover: the sender read from
181
+ authenticated bytes, a successful binding, refusal of a foreign key, refusal of a replayed consent,
182
+ refusal of an edited consent, absence reported as `none`, an unknown version refused by name, an unknown
183
+ chain refused rather than guessed, and a digest that changes when any settlement field changes.
184
+
185
+ #### Also validated as part of `avm-mesh`
186
+
187
+ The same module also ships as `avm_mesh.ac2` inside
188
+ [`avm-mesh`](https://github.com/chopmob-cloud/avm-mesh), whose own clean-room gate is green including an
189
+ AC2 stage: **567 tests, 0 skipped, 0 failed**, with the consent binding passing on both chains against the
190
+ installed wheel. This package is the same code with a narrower dependency and a CLI.
191
+
192
+ ### Interop with the real AC2 stack
193
+
194
+ A same-language round trip proves only that my encoder agrees with my decoder, so
195
+ the seam is tested against bytes produced by the **real** AC2 conventions:
196
+
197
+ `tests/interop/interop_emit.mjs` uses Node's `base64url` and a JCS encoder of the
198
+ kind the reference implementation ships. `tests/test_interop_ac2.py` then requires
199
+ the Python side to accept that output.
200
+
201
+ This found a live defect. AC2's stack emits **base64url**; `base64.b64decode(...,
202
+ validate=True)` rejects `-` and `_`, so a genuine AC2 signature was refused as "not
203
+ valid base64". Every prior test encoded with Python's standard alphabet and decoded
204
+ with the same alphabet, so none of them could see it. The decoder now accepts both
205
+ alphabets strictly — characters outside both are still refused — and reverting that
206
+ one line turns 2 tests red.
207
+
208
+ It also pins that the two implementations agree on the canonical payload **byte for
209
+ byte**, not merely in digest: an independent JCS implementation must produce exactly
210
+ the bytes this package signs.
211
+
212
+ | Interop check | Result |
213
+ |---|---|
214
+ | Real base64url signature verifies | PASS |
215
+ | Node and Python agree on canonical bytes and digest | PASS |
216
+ | Standard base64 still accepted | PASS |
217
+ | Tampered url-alphabet signature still refused | PASS |
218
+ | Characters outside both alphabets refused | PASS |
219
+
220
+ **What the SDK and service documentation establish:** `agent.request` is
221
+ documented as *verb-agnostic*, so a request is not restricted to transactions; the
222
+ SDK's signing path is payload-agnostic, single-use and thread-bound; and the request
223
+ schema carries `display_hint` for previewing payloads it does not recognise.
224
+ The AC2 service and SDK therefore **permit** an arbitrary canonical payload.
225
+
226
+ **What no test here can establish:** that the *shipped wallet application* will
227
+ approve a payload it does not recognise as a transaction or a message. That is a
228
+ product policy inside the mobile app, not something the protocol or the SDK
229
+ publishes. It requires a physical device and a real account.
230
+
231
+ So the accurate claim is: **the mechanism and the wire encoding are tested against
232
+ the real stack; the wallet's approval policy for a non-transaction payload is
233
+ unverified.** An integration against a live wallet may find that the app shows the
234
+ payload as opaque, or declines it — in which case the fallback is to carry the
235
+ consent over the transaction signature the wallet already produces
236
+ (`sig_hint: transaction-algorand`), which needs no new wallet behaviour.
237
+
238
+ ## Two consent flavours
239
+
240
+ The package ships two ways to bind a consent, because they depend on different
241
+ things and one of them has no dependency on wallet policy.
242
+
243
+ ### 1. Canonical-payload consent (`avm_ac2.consent`)
244
+
245
+ The controller signs the settlement as a canonical JSON envelope. Rich — the
246
+ consent covers the amount, asset and chain exactly as the receipt describes them —
247
+ but it asks the wallet to approve a payload that is not a transaction.
248
+
249
+ ### 2. Transaction-bound consent (`avm_ac2.txn_consent`)
250
+
251
+ The consent is carried over the **transaction signature the wallet already
252
+ produces** when it approves a payment (`sig_hint: transaction-algorand`), so
253
+ nothing new is asked of the wallet. This is the fallback for the case where a
254
+ wallet declines to approve an opaque payload.
255
+
256
+ The preimage is `"TX" + canonically-encoded(restored Transaction)`, where the
257
+ genesis fields consensus strips on encode are restored on decode. That derivation
258
+ is **verified, not assumed**: `preimage_digest()` must reproduce the bundle's own
259
+ `transaction.txid`, and the tests assert it on both chains. An earlier version
260
+ re-encoded the STIB's `txn` map directly, omitting `gen`/`gh`, and produced a
261
+ confident 52-character base32 string that was simply the wrong transaction — the
262
+ txid equality is what caught it.
263
+
264
+ | | canonical-payload | transaction-bound |
265
+ |---|---|---|
266
+ | Wallet must approve an opaque payload | **yes** | no |
267
+ | Binds consent to amount/asset as described | yes | no — binds to the transaction |
268
+ | Reaches `sender_bound` | by key comparison | **by construction** |
269
+ | Needs `txn_consent.signing_preimage` | — | yes, verified against `txid` |
270
+
271
+ Neither proves a hardware passkey was used: that limit is shared and comes from the
272
+ AC2 wire format, not from the choice of flavour.
273
+
274
+ ### Integrator warning: do not build the payload with a transaction constructor
275
+
276
+ `algokit-utils`' `bytesForSigning.transaction` drops the `gen` (genesis id string)
277
+ key while keeping `gh` (the genesis hash), because on the *constructor* path it
278
+ expects a node to fill that back in. A payload built that way is **not** the
279
+ transaction the chain committed to: on the real Voi capture, removing `gen` changes
280
+ the txid from `75LUFZZNQNOPS3SLQRHZZKZIECEEVGGP4N3ZZ2UU2UKFFJU5WG4A` to
281
+ `XGEHZIIAVMQ64YVG3GOWUO4YG3OAQMZE4O2NGZDXNCQOXDFYGTVQ`.
282
+
283
+ Use `avm_ac2.txn_consent.signing_preimage(bundle, chain)` to produce the payload.
284
+ It restores `gen` and is checked against the bundle's own `transaction.txid` on both
285
+ chains, so a wrong preimage fails loudly instead of producing a confident wrong
286
+ transaction. `tests/test_txn_consent.py` pins this, including an assertion that the
287
+ gen-less form does *not* reproduce the txid.
288
+
289
+ This does not affect the wallet: it signs the bytes it is handed, not bytes it
290
+ builds. It affects the agent, which is the side this package is for.
291
+
292
+ ### What is *not* demonstrated
293
+
294
+ - **No signature has been produced by a real wallet.** Every consent in this
295
+ repository is generated by a test or the demo. The chain evidence is real; the
296
+ approval is synthetic, and the tests and demo output say so on every run.
297
+ - **One capture per chain, one endpoint.** This proves the mechanism, not witness
298
+ independence.
299
+ - **AC2 is a Draft.** The wire fields here are from `ac2-sdk` 1.0.0 and the
300
+ `ac2.md` Draft as published. If the SDK starts carrying WebAuthn material,
301
+ `consent_present` could honestly become a stronger claim — that would be a new
302
+ consent version, never a reinterpretation of version 1.
303
+
304
+ ## Licence
305
+
306
+ Apache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).