Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/sdk/python/ap2/sdk/sdjwt/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ap2.sdk.utils import b64url_decode, b64url_encode
from jwcrypto.jwk import JWK
from pydantic import BaseModel
from sd_jwt.issuer import SDJWTIssuer

Check warning on line 18 in code/sdk/python/ap2/sdk/sdjwt/common.py

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (SDJWT)


HashMode = Literal['sd_hash', 'issuer_jwt_hash']
Expand Down Expand Up @@ -83,7 +83,7 @@
cnf = self._find_cnf()
if isinstance(cnf, dict) and 'jwk' in cnf:
jwk_model = JsonWebKey.model_validate(cnf['jwk'])
return JWK(**jwk_model.model_dump(exclude_none=True))
return JWK(**jwk_model.model_dump(mode='json', exclude_none=True))
return None

def _find_cnf(self) -> dict[str, Any] | None:
Expand Down Expand Up @@ -276,9 +276,9 @@
header_params: dict[str, Any],
add_decoy_claims: bool,
serialization_format: str,
) -> SDJWTIssuer:

Check warning on line 279 in code/sdk/python/ap2/sdk/sdjwt/common.py

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (SDJWT)
"""Create an ``SDJWTIssuer`` with AP2's common issuer options."""

Check warning on line 280 in code/sdk/python/ap2/sdk/sdjwt/common.py

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (SDJWT)
return SDJWTIssuer(

Check warning on line 281 in code/sdk/python/ap2/sdk/sdjwt/common.py

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (SDJWT)
user_claims=claims,
issuer_key=issuer_key,
holder_key=None,
Expand Down
21 changes: 21 additions & 0 deletions code/sdk/python/ap2/tests/kb_sd_jwt_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest

from ap2.sdk.generated.open_payment_mandate import OpenPaymentMandate
from ap2.sdk.sdjwt import (

Check warning on line 15 in code/sdk/python/ap2/tests/kb_sd_jwt_tests.py

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (sdjwt)
compute_issuer_jwt_hash,
compute_sd_hash,
kb_sd_jwt,
Expand Down Expand Up @@ -137,6 +137,27 @@
)


def test_verify_accepts_cnf_jwk_with_use_and_alg(issuer_key):
"""A prior hop whose ``cnf.jwk`` carries ``use`` and ``alg`` still verifies."""
holder = JWK.generate(kty='EC', crv='P-256', use='sig', alg='ES256')
assert json.loads(holder.export_public())['use'] == 'sig'
prev = _root_open(issuer_key, holder)
result = _create(
prev_token=prev,
holder_key=holder,
payload=sample_payment_mandate(),
aud='a',
nonce='n',
)
_verify(
result.sd_jwt_issuance,
prev,
issuer_key,
expected_aud='a',
expected_nonce='n',
)


def test_verify_accepts_issuer_jwt_hash_mode(issuer_key):
holder = JWK.generate(kty='EC', crv='P-256')
prev = _root_open(issuer_key, holder)
Expand Down
Loading