Skip to content

fix(sdjwt): dump cnf.jwk in JSON mode so keys with "use" verify - #383

Open
aeoess wants to merge 1 commit into
google-agentic-commerce:mainfrom
aeoess:fix-cnf-jwk-json-mode
Open

aeoess wants to merge 1 commit into
google-agentic-commerce:mainfrom
aeoess:fix-cnf-jwk-json-mode

Conversation

@aeoess

@aeoess aeoess commented Oct 17, 2026

Copy link
Copy Markdown

Description

Fixes #372

ParsedToken.cnf_jwk rebuilt the holder key with model_dump(exclude_none=True). In Python mode that returns use as the Use.sig enum member, and jwcrypto then rejects the key, so kb_sd_jwt.verify raised InvalidJWSSignature for any hop whose previous cnf.jwk carried "use": "sig". This change passes mode='json', the same fix #355 applies in delegate_claims_from_model. #355 does not touch cnf_jwk, so the two do not overlap.

The added test test_verify_accepts_cnf_jwk_with_use_and_alg builds a hop whose root cnf.jwk includes use and alg. It fails on main (InvalidJWSSignature) and passes with this change. A cnf.jwk without use still verifies as before.

Testing: pytest code/sdk/python/ap2/tests gives 187 passed and 2 failed. The same 2 tests (kb_sd_jwt_intermediate_tests.py::test_verify_rejects_aud_mismatch and test_verify_rejects_nonce_mismatch) fail identically on main without this change. ruff check and ruff format --check pass on both changed files.

  • Follow the CONTRIBUTING guide
  • Conventional commit title
  • Tests and linter pass for the changed files

@aeoess
aeoess requested a review from a team as a code owner October 17, 2026 19:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A delegation hop never verifies when cnf.jwk carries "use" (ParsedToken.cnf_jwk hands jwcrypto an enum)

1 participant