feat(sdk): add versioned delegate-SD-JWT golden vectors + consumer test - #307
Open
vishkaty wants to merge 1 commit into
Open
feat(sdk): add versioned delegate-SD-JWT golden vectors + consumer test#307vishkaty wants to merge 1 commit into
vishkaty wants to merge 1 commit into
Conversation
Add a keyed, versioned golden-vector set for the AP2 delegation chain layer (the SD-JWT ~~ wire), addressing issue google-agentic-commerce#303. Every vector is minted by the real reference SDK (ap2.sdk) rather than hand-forged, so the committed serializations are authoritative. Vectors (delegate_sd_jwt_vectors/delegate_sd_jwt_vectors.json): - root-single-sd-jwt: a lone SD-JWT (ends with ~, zero ~~ joins) - single-hop-payment-chain: one hop via MandateClient.present (one ~~) - multi-hop-payment-chain: Bank -> SA -> CP -> Merchant (two ~~ joins) - single-hop-checkout-chain: the checkout mandate family (one ~~) delegate_sd_jwt_vector_tests.py consumes the frozen set and asserts the on-wire invariants (single ends ~, N-segment chain has N-1 ~~ joins) and that each vector verifies against the SDK with the expected resolved payloads. generate_vectors.py regenerates the set from pinned P-256 keys; salts and ES256 signatures are randomized by design, so the committed JSON is the frozen artifact the test verifies.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a versioned, self-describing golden-vector set for the delegate-SD-JWT chain layer, plus a consumer test that verifies each vector against the SDK and asserts the compact-serialization wire invariants. Addresses #303.
The SDK builds delegation chains inline in
chain_tests.pybut ships no on-disk golden-vector artifact, so a spec/format change can silently alter the~~-joined wire without a frozen reference catching it. These vectors are that reference.What's included
code/sdk/python/ap2/tests/delegate_sd_jwt_vectors/delegate_sd_jwt_vectors.json— 4 frozen vectors, each with its public JWK, kids, verification inputs, and anexpectedblock (hop_count,double_tilde_joins,ends_with_tilde, payload assertions).generate_vectors.py— the generator (pinned keys), mirroring the SDK's canonical Bank → Shopping-Agent → Credentials-Provider → Merchant flow.delegate_sd_jwt_vector_tests.py— consumer/verifier.All four vectors are minted by the real
ap2.sdk(sd_jwt.create/kb_sd_jwt.create/MandateClient.present) — not hand-authored strings:~~joins~root-single-sd-jwtsingle-hop-payment-chainmulti-hop-payment-chainsingle-hop-checkout-chainVerification
~; an N-segment chain has exactly N−1~~joins).InvalidJWSSignature; collapsing a~~→~→ wire-shape + verify failure. Both revert clean.kb_sd_jwt_intermediate_testsfailures pre-exist on a pristine checkout).ruff check/formatclean on the new Python.Reproducibility
Keys are pinned and embedded, so signature verification is fully deterministic on any machine. Per RFC 9901 the compact serializations are intentionally not byte-reproducible (random disclosure salts; randomized ECDSA
k) — regeneration yields semantically identical, byte-different vectors, so the committed JSON is the frozen artifact the consumer test verifies. This is documented ingenerate_vectors.pyand the JSON'sreproducibilityblock.Note
Two minimal repo-config edits keep spellcheck CI green on the new files: a
.cspell.jsonignore-glob for the vector JSON (base64 crypto blobs) and addingsdjwtto the custom dictionary. Happy to adjust if you'd prefer a different exclusion mechanism.Closes #303