Skip to content

fix(schema): machine-enforce the P-521/ES512 key pairing in profile.json#625

Open
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/profile-p521-es512-pairing
Open

fix(schema): machine-enforce the P-521/ES512 key pairing in profile.json#625
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/profile-p521-es512-pairing

Conversation

@vishkaty

Copy link
Copy Markdown
Contributor

Problem

profile.json encodes the JWK curve↔algorithm binding as schema constraints — but only for three of the four curves it names. There are if/then rules for P-256 → ES256, P-384 → ES384, and Ed25519 → EdDSA, and none for P-521.

The effect, checked with the ucp-schema validator (same one CI uses):

Key published in keys[] profile.json validation
crv: P-521, alg: ES512 (correct) ✅ Valid
crv: P-521, alg: ES256 (mismatched) ✅ Valid — not caught
crv: P-256, alg: ES384 (mismatched) ❌ Rejected

So a P-521 signing key can be published with an algorithm that contradicts its curve and pass validation, while the identical mistake on a P-256 key is rejected. This is the same class of gap as #571 (a schema-valid artifact depending on a curve/algorithm pairing the schema never defines), at the key-publication layer.

Change

One allOf rule — P-521 pairs with ES512 — mirroring the existing P-256/P-384 rules exactly, plus P-521/ES512 added to the crv/alg examples and the alg "MUST match" description. +10/−5, no reformatting.

It is conditional well-formedness only: it constrains a P-521 key to ES512 when one is published; it does not require any party to support ES512. So it is orthogonal to whether ES512 stays AP2-scoped (#618) or becomes UCP-wide — either way, a P-521 key that is published should be correctly paired.

Verification (ucp-schema)

  • The mismatched P-521 key is now rejected; a correct P-521/ES512 key still validates; an alg-less P-521 key still validates (verifiers derive the algorithm from crv); P-256/P-384/OKP keys are unaffected.
  • ucp-schema lint source/ (96 files pass), validate_examples.py (276 passed, 0 failed), validator unit tests (43 passed), cspell clean.

Relation to #618

This complements #618 rather than overlapping it — different file, no conflict. #618 documents the AP2 algorithm set and the alg↔curve binding in prose and pseudocode (including a P-521/ES512 JWK example); this makes that binding machine-enforced at the schema layer. I verified that #618's own example JWK validates against this rule, so the two land cleanly together. Happy to defer to @ShuoRen-TT and the maintainers on how to sequence or combine them.

Relates to #571.

profile.json encodes the curve<->alg binding as schema constraints for P-256,
P-384, and Ed25519, but not for P-521. A P-521 key published with a mismatched
alg (e.g. ES256) therefore passes profile validation, while the identical
mistake on a P-256 key is rejected. This makes the binding machine-checkable
and symmetric for the ES512 case, complementing the prose/pseudocode binding
proposed in Universal-Commerce-Protocol#618.

Conditional well-formedness only: it constrains a P-521 key to alg ES512 when
one is published; it does not require any party to support ES512, so it stays
consistent with keeping ES512 AP2-scoped. Verified with ucp-schema: a mispaired
P-521 key is now rejected; a correct P-521/ES512 key, and an alg-less P-521 key
(verifier derives the algorithm), still validate; P-256/P-384/OKP keys are
unaffected.
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Jul 21, 2026
@carolinerg1 carolinerg1 added status:under-review gov:needs-tc-review and removed status:needs-triage Signal that the PR is ready for human triage labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants