Repository navigation
feat(client): add identity.v1 claim signing and verification - #2223
Merged
Merged
Conversation
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 29, 2026 16:43
65ec3ee to
5ef8955
Compare
ramizpolic
force-pushed
the
feat/identity-01-claim-types
branch
from
September 30, 2026 08:05
79099c3 to
c7cf7c5
Compare
ramizpolic
marked this pull request as draft
September 30, 2026 08:23
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 08:58
5ef8955 to
fbd816b
Compare
ramizpolic
force-pushed
the
feat/identity-01-claim-types
branch
from
September 30, 2026 11:08
c7cf7c5 to
6c6ff45
Compare
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 11:09
fbd816b to
47d8a8a
Compare
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 12:37
47d8a8a to
bd56a05
Compare
ramizpolic
marked this pull request as ready for review
September 30, 2026 12:37
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 12:52
bd56a05 to
c16a3ec
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
csirmazbendeguz
previously approved these changes
Sep 30, 2026
lgecse
previously approved these changes
Sep 30, 2026
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 13:48
c16a3ec to
d1af0ab
Compare
ramizpolic
enabled auto-merge (squash)
September 30, 2026 13:57
tkircsi
reviewed
Sep 30, 2026
ramizpolic
disabled auto-merge
September 30, 2026 14:06
ramizpolic
dismissed stale reviews from csirmazbendeguz and lgecse
via
September 30, 2026 14:12
f6c7482
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
September 30, 2026 14:12
d1af0ab to
f6c7482
Compare
tkircsi
reviewed
Sep 30, 2026
ramizpolic
added a commit
that referenced
this pull request
Oct 1, 2026
Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on #2223; nothing outside these packages calls any of this yet. Closes #2214 Signed-off-by: Ramiz Polic <[email protected]>
lgecse
previously approved these changes
Oct 1, 2026
ramizpolic
added a commit
that referenced
this pull request
Oct 1, 2026
Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on #2223; nothing outside these packages calls any of this yet. Closes #2214 Signed-off-by: Ramiz Polic <[email protected]>
ramizpolic
added a commit
that referenced
this pull request
Oct 1, 2026
Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on #2223; nothing outside these packages calls any of this yet. Closes #2214 Signed-off-by: Ramiz Polic <[email protected]>
Adds the cryptographic proof for a Claim, split into two packages under client/utils, mirroring how sign.v1 keeps api/sign/v1 free of crypto and puts the logic in client/utils/cosign and client/utils/verify: - client/utils/jws: payload-agnostic detached JWS (RFC 7515) signing and verification. The algorithm is derived from the key's own type (ES256, ES384, EdDSA, RS256), never from the token's self-declared alg header. RSA keys under 2048 bits are rejected. Verify takes variadic keys and succeeds if any one validates. KeySigner and KeyCertSigner load PEM keys, including password-protected PKCS#8 (ENCRYPTED PRIVATE KEY), with the password passed in by the caller; jws never prompts or reads env. - client/utils/identity: claim-level Sign and Verify on top of jws. Sign takes WithSubjectChecker and WithCertificateProvider options (e.g. a KeyCertSigner's SubjectMatchesCertificate and CertificateDER for SPIFFE) instead of discovering interfaces on the signer. Verify checks record_cid, subject, and expiry, then verifies against the given keys. A claim is signed over Claim.GetPayload, a canonical JSON encoding of record_cid, role, subject, signed_at, and expires_at, excluding signature and certificate. role is part of the payload, so a signature made for one role cannot be replayed as the other. Verify takes already-resolved public keys and does no key resolution itself, so it has no server, CLI, reconciler, or network awareness. Resolving keys (DNS, DID, JWKS, SPIFFE trust bundle) is a follow-up. Closes #2222 Signed-off-by: Ramiz Polic <[email protected]>
Signed-off-by: Ramiz Polic <[email protected]>
- KeyCertSigner now keeps the parsed certificate instead of re-parsing its DER on every SubjectMatchesCertificate call, which also stops a parse failure from silently reading as "subject does not match". - NewKeyCertSigner refuses a private key that does not belong to the certificate. Before, a mismatched pair signed fine and every verification then failed far from the cause. - identity.Sign no longer mutates the caller's claim on failure: it signs a copy and writes RecordCid, SignedAt, Signature and Certificate back only once signing has succeeded. Re-signing also clears a stale Certificate rather than leaving it behind. - A certificate provider that returns nothing is now an error. Before, it produced a claim whose optional Certificate was present but empty, which claims to carry a certificate and carries none. Adds tests for each of the above, and for previously uncovered paths: the file loaders, the legacy EC and RSA PEM formats, bad key material, a raw DER certificate, and Verify's guard branches (including a malformed expiry). Signed-off-by: Ramiz Polic <[email protected]>
NewKeySignerFromFile and NewKeyCertSignerFromFile were thin wrappers over os.ReadFile and the byte-based constructors, and nothing called them. jws otherwise does no I/O: it takes bytes, and leaves prompts, the environment and files to the caller. The CLI will decide how it loads keys (path, inline PEM or KMS), so a file loader here was a guess about its needs. Callers read the files themselves and use NewKeySigner or NewKeyCertSigner. Signed-off-by: Ramiz Polic <[email protected]>
…ate option Drop KeyCertSigner, WithSubjectChecker and WithCertificateProvider. Sign now takes a single WithCertificate(cert) option and checks, before signing, that the certificate belongs to the signer's key and names the claim subject as a URI SAN. jws.Signer exposes Public() so the check needs no extra type. Signed-off-by: Ramiz Polic <[email protected]>
ramizpolic
force-pushed
the
feat/identity-02-claim-crypto
branch
from
October 1, 2026 09:19
3e7cce7 to
56b1729
Compare
ramizpolic
added a commit
that referenced
this pull request
Oct 1, 2026
Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on #2223; nothing outside these packages calls any of this yet. Closes #2214 Signed-off-by: Ramiz Polic <[email protected]>
tkircsi
reviewed
Oct 1, 2026
tkircsi
left a comment
Contributor
There was a problem hiding this comment.
Nice improvements! One nit.
lgecse
approved these changes
Oct 1, 2026
ramizpolic
added a commit
that referenced
this pull request
Oct 1, 2026
Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on #2223; nothing outside these packages calls any of this yet. Closes #2214 Signed-off-by: Ramiz Polic <[email protected]>
vijit-vishnoi
pushed a commit
to vijit-vishnoi/agntcy-dir
that referenced
this pull request
Oct 10, 2026
* feat(client): add identity key resolvers and safefetch Adds client/utils/identity/resolvers: one resolver per key-discovery scheme, each returning the candidate public keys for a claim's subject. A resolver only finds keys; it never checks a signature. Pass the result to identity.Verify, which does all of the cryptography and accepts the claim if any one key validates. Resolve(ctx, subject, certificate) ([]crypto.PublicKey, error) - DNS: "_agntcy-key.<domain>" TXT records, "v=akv1;key=<base64 SPKI>". - WellKnown: https subjects, the host's /.well-known/jwks.json. Skips encryption-only and symmetric keys. - DID: did:web (document over HTTPS, whose id must equal the subject) and did:key (self-certifying, no network) for ed25519, P-256, P-384, RSA. did:web segments are validated so an escaped "/" or ".." can't steer the request to another path or host. - SPIFFE: the key comes from the claim's X.509-SVID, trusted only after x509svid.ParseAndVerify validates it against the subject's trust-domain bundle and its SPIFFE ID equals the subject. A trust domain with no bundle fails closed. Each resolver is built with an explicit constructor; there is no registry or self-registration. Network access goes through a small Fetcher interface, so resolvers are tested against fakes with no live network. Every resolver caps the number of keys it will return. utils/safefetch is the SSRF-guarded HTTPS client did and wellknown use by default: https only, non-public addresses refused at dial time after DNS resolution (loopback, RFC 1918, link-local, shared address space, IPv4- mapped IPv6), redirects bounded and unable to downgrade to http, and a response size cap. Stacked on agntcy#2223; nothing outside these packages calls any of this yet. Closes agntcy#2214 Signed-off-by: Ramiz Polic <[email protected]> * refactor(client): split identity resolvers into one package per scheme Each resolver now lives in its own package under resolvers/, with a package name that reads at the call site: didresolver.New(fetch) resolvers/did dnsresolver.New(opts...) resolvers/dns wellknownresolver.New(fetch) resolvers/wellknown spifferesolver.New(bundles) resolvers/spiffe The type in each is Resolver, and spifferesolver.LoadBundles replaces LoadSPIFFEBundles. The parent resolvers package keeps only the public contract: the Resolver and Fetcher interfaces and ErrNoKeys. Code the schemes share moves to resolvers/internal/keyutil (key normalization, host parsing, the key-count cap, JWK conversion), and the test fixtures to resolvers/internal/testutil, so neither is importable from outside resolvers/. dnsresolver gains a WithLookupTXT option, since the end-to-end test now lives outside the package. Each scheme wraps the shared key-count error with its own name, so a failure reads "dns: no usable public keys found at ...". No behavior change: the same 21 test functions and 39 subtests pass. Signed-off-by: Ramiz Polic <[email protected]> * refactor(client): move key helpers into jws and drop the shared keyutil - ToPublicKey and PublicKeyFromJWK move to client/utils/jws, where the set of usable key types is already decided. ToPublicKey now reuses jwsAlgorithmFor, so it accepts exactly what jws can verify with (and refuses unsupported curves and RSA keys under 2048 bits up front) instead of keeping a second, separate type switch. - Finish and the per-subject key cap are removed: a resolver returns every key it finds. Each resolver still returns ErrNoKeys rather than an empty result with a nil error. - ParseHost is removed. It only mattered where a URL is built from the subject: wellknown now parses the subject as a URL and refuses userinfo (in "https://[email protected]" the host is evil.com), and did:web validates its host inline. dns builds a TXT name, not a URL, so it only rejects an empty subject. - internal/keyutil is deleted. Signed-off-by: Ramiz Polic <[email protected]> * test(client): share crypto fixtures across jws, identity and resolvers The jws and identity tests each carried a byte-identical generateKey, and PKCS#8 encoding, key generation and self-signed certificates were written out in four places. The resolvers' testutil added a third copy. - client/utils/internal/testutil is now the one shared package, importable by jws, identity and the resolvers and by nothing outside client/utils: key generators (including a NewKey(kind) that replaces both generateKey copies), PKCS#8 and certificate PEM helpers, a self-signed certificate, JWKS, a fake fetcher, and RequireSameKeys. It imports none of this repo's packages, so it cannot form an import cycle with their tests. - Fixtures only one scheme uses move into that scheme's tests: the DID document and did:key builders, the DNS TXT key encoding, a JWK with a "use", and the test CA, SVID issuer and trust bundle. - The parent-package end-to-end test splits into each scheme's package, so a scheme's sign -> resolve -> verify test uses only its own fixtures. The shared flow lives in resolvers/internal/claimtest, kept apart from testutil because it imports identity and jws. The compile-time contract assertions become a TestResolver_SatisfiesContract per package. - The two 1024-bit RSA key generations in the jws tests share one helper. No production code changes. Every previous test still runs: the five end-to-end tests are now TestEndToEnd* in their own packages, and the security mutations (SPIFFE ID, DID id and host, userinfo, key/cert match, RSA floor and others) are all still caught. Signed-off-by: Ramiz Polic <[email protected]> * fix(client): address review feedback on identity resolvers - safefetch: also refuse the IPv6 transition ranges (NAT64, 6to4, Teredo, discard, documentation, deprecated IPv4-compatible) and the IPv4 documentation and relay ranges, which can reach a blocked IPv4 target - did:web: build the document path from the decoded segments so an escaped segment is not escaped a second time - did:key: apply the shared jws key filter, so an RSA key below the minimum size is no longer returned as a usable key - jws: refuse typed-nil and incomplete ECDSA/RSA keys instead of panicking - jws: honor key_ops on a JWK and require verify when it is present Signed-off-by: Ramiz Polic <[email protected]> * test(client): merge claimtest into testutil Move the sign-resolve-verify claim helpers into client/utils/internal/testutil so the shared test code is one package. testutil now imports jws and identity, so their tests become external (package jws_test, identity_test). Signed-off-by: Ramiz Polic <[email protected]> * fix(client): address second round of review feedback on resolvers - did:web: only accept keys authorized by assertionMethod (by reference or embedded) instead of every verificationMethod - jws: refuse Ed25519 keys of the wrong length instead of panicking - safefetch: also refuse deprecated site-local fec0::/10 - safefetch: try every validated address in order rather than only the first Signed-off-by: Ramiz Polic <[email protected]> * test(client): build the small RSA fixture from primes CodeQL flags rsa.GenerateKey with 1024 bits. The key is deliberately weak, to test the 2048-bit floor, so assemble it from two random primes instead. Signed-off-by: Ramiz Polic <[email protected]> * Revert "test(client): build the small RSA fixture from primes" The 1024-bit key is deliberately weak, to test the 2048-bit floor. The CodeQL finding is a false positive and will be dismissed rather than worked around. This reverts commit dad0d7b. Signed-off-by: Ramiz Polic <[email protected]> --------- Signed-off-by: Ramiz Polic <[email protected]>
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
Second PR in the identity/ownership claims epic (#2212), following #2221 (claim types, merged). Adds the cryptographic proof for a
Claim: signing and verification, as two small packages underclient/utilswith no server, CLI, reconciler, or key-resolution awareness.The split mirrors how
sign.v1already works here:api/sign/v1has no crypto, and the logic lives inclient/utils/cosignandclient/utils/verify.api/identity/v1keeps the same shape (proto types, payload, referrer marshaling) and imports no crypto library.client/utils/jws: payload-agnostic detached JWS (RFC 7515)Sign(signer, payload)andVerify(jws, payload, keys...). The algorithm is derived from the key's own type (ES256, ES384, EdDSA, RS256), never from the token's self-declaredalgheader, so a token can't pick its own verification algorithm.Verifytakes variadic keys and succeeds if any one validates, so a resolver can hand over a whole key set (a DNS TXT record set, a JWKS). An unusable key is skipped rather than aborting, and no keys is an explicit error.KeySignerloads a PEM key:EC PRIVATE KEY,RSA PRIVATE KEY,PRIVATE KEY, and password-protectedENCRYPTED PRIVATE KEY(PKCS#8 PBES2, including Ed25519).jwstakes bytes and does no I/O of its own: the password is passed in by the caller (nilfor an unencrypted key), and reading key files, prompting, and the environment (COSIGN_PASSWORD/--password-stdin) stay with the CLI. Decryption usesgithub.com/youmark/pkcs8, already in the module graph through cosign, sogo.modonly loses its// indirectmarker.Signerinterface isSign(payload)plusPublic(), so callers can check a certificate against the signer's key without a second type.client/utils/identity: claim-level glue on top ofjwsSign(claim, recordCID, signer, opts...)setsRecordCid,SignedAt, andSignature. It signs a copy and writes the fields back only once signing has succeeded, so a failedSignleaves the caller's claim exactly as it was, and re-signing replaces a staleCertificaterather than leaving it behind.WithCertificate(cert)embeds an X.509 certificate (PEM or DER) in the claim, for subjects whose proof is a certificate rather than a published key (SPIFFE X.509-SVIDs). Before signing,Signchecks that the certificate belongs to the signer's key (a mismatched pair fails here instead of producing signatures every verifier rejects) and that it names the claim's subject as a URI SAN. An unparsable or empty certificate is an error, never a claim whose optionalCertificateis present but empty.Verify(claim, recordCID, expectedSubject, keys...)checksrecord_cid, subject, and expiry (a malformedexpires_atis an error, not silently ignored), then verifies the signature against the given keys. It returns(bool, error).Signed payload
(*Claim).GetPayload()inapi/identity/v1returns a canonical JSON encoding ofrecord_cid,role,subject,signed_at, andexpires_at, excludingsignatureandcertificate, which don't exist yet at signing time.roleis part of it, so a signature made for one role can never be replayed as the other, regardless of which referrer type the claim is stored under. Note thatroleis the proto enum name (CLAIM_ROLE_IDENTITY), so that string is what gets signed.Verifytakes already-resolved public keys and does no resolution itself, so it needs no network or resolver mocking to test. Resolving keys (DNS, DID, JWKS, SPIFFE trust bundle) is a separate follow-up.Contains
api/identity/v1/claim.go(+ test):Claim.GetPayloadclient/utils/jws/{jws,signer}.go(+ tests)client/utils/identity/{sign,verify}.go(+ tests)client/go.mod,client/go.sum:lestrrat-go/jwx/v2, andyoumark/pkcs8as a direct dependencyNothing outside these packages calls any of this yet.
Verification
go build,go vet,go test, and golangci-lint (CI-pinned 2.13.2, diff-only and over the full packages) pass for theapiandclientmodules;go mod tidyleaves no drift. Statement coverage is 95.5% forjwsand 97.6% foridentity.jws: sign/verify round-trips for ES256, ES384, EdDSA, and RS256; tampered payload, wrong key, wrong key type, and unsupported key type are rejected; multi-key verification; key loading from PEM (PKCS#8, legacy EC and RSA), bad key material; encrypted-key loading (missing password, wrong password, password ignored for an unencrypted key); RSA keys under 2048 bits rejected.identity: round-trips for both roles, and with a certificate (PEM and raw DER); a tampered payload, a wrong subject, a mismatched role (a claim signed as identity must not verify as owner), an expired claim, a malformed expiry, and a wrongrecord_cideach fail distinctly;Signleaves the claim untouched when the signer fails, the subject isn't covered by the certificate, the certificate belongs to another key (same or different type), or the certificate is empty or garbage; re-signing clears a stale certificate; invalid-input errors.api/identity/v1:GetPayloadoutput for all three roles (unspecified, identity, owner), asserting exact bytes and field order.Resolves #2222