Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the Ed25519PublicJwk class to represent Ed25519 public keys as RFC 8037 Octet Key Pair (OKP) JSON Web Keys, along with corresponding tests and dependency updates. The review feedback focuses on performance optimizations and code simplification within the new model. Key recommendations include avoiding unnecessary memory allocations by utilizing Uint8List.sublistView, UnmodifiableUint8ListView, and setRange instead of list copying and spread operators, as well as simplifying the == operator and hashCode implementation to compare only the unique x coordinate.
239902c to
8729a03
Compare
22bf631 to
485ea5f
Compare
8729a03 to
40a72b8
Compare
485ea5f to
2011823
Compare
jtmcdole
left a comment
There was a problem hiding this comment.
You're going to have a bad time with ci.yaml checks. this is why I started a thread to talk about removing it from cocoon as a required passing test.
There was a problem hiding this comment.
nit: I personally do not like barrel imports.
jtmcdole
left a comment
There was a problem hiding this comment.
This PR adds Ed25519PublicJwk and isValidJwksKeyId to dummy_ci as layer 2 of 7 (#5229 to #5235), mirroring app_dart/lib/src/model/jwks/ed25519_jwk.dart. Static checks, formatting, dart compile exe, and all 10 unit tests pass locally (54/54 lines covered, max cognitive complexity 6). The main items to address are boundary validation gaps (computeThumbprintForX, isValidJwksKeyId, fromPublicKeyBytes, mixed PEM blocks), missing negative test assertions, day-0 drift against app_dart, and one open barrel-export nit.
against HEAD and local scratch runs (Executed / Read). Active flags: codefu-review three-lens pass (Simplicity/Scope, Resilience/Security, Modern Dart/Tests) with local throwaway verification (SAFE_FOR_LOCAL_EXECUTION, author_association: MEMBER).
🤖 Agent-generated
| final fromBytes = Ed25519PublicJwk.fromPublicKeyBytes( | ||
| decodeBase64UrlUnpadded(rfcExpectedX), | ||
| ); | ||
| expect(fromBytes, parsed); |
There was a problem hiding this comment.
Nothing verifies that two distinct keys compare unequal, that mutating the input list after fromPublicKeyBytes leaves the JWK intact, or that toJoseKey() rejects a JWS signed by a different key. A broken operator == (I removed && other.x == x locally and all 6 tests passed) or a missing defensive copy goes undetected.
Assert expect(parsed, isNot(rfc8410Parsed)), mutate the byte list passed to fromPublicKeyBytes and confirm fromBytes.publicKeyBytes is unchanged, and verify rfc8037SignedJws fails with JoseException against rfc8410Parsed.toJoseKey().
Details
Impact: A broken operator == (I removed && other.x == x locally and all 6 tests passed) or a missing defensive copy goes undetected.
Evidence (Executed): Mutated ed25519_jwk.dart:173 to drop && other.x == x and ran dart test test/model/ed25519_jwk_test.dart; all 6 tests still passed.
rfc8410Parsed is already constructed three lines below at line 69, so both the negative equality check and the wrong-key JWS rejection test need only a few lines.
🤖 Agent-generated
| throwsFormatException, | ||
| ); | ||
| expect( | ||
| () => Ed25519PublicJwk.fromPublicKeyPem( |
There was a problem hiding this comment.
Every negative test uses bare throwsFormatException, even though fromPublicKeyPem has four distinct FormatException branches. Because package:pem silently skips invalid base64, a broken fixture hits blocks.isEmpty and still passes. Bare throwsFormatException cannot distinguish a regression in SPKI validation or multi-block detection from an unrelated PEM parse failure.
Match the failure reason on each case with throwsA(isA<FormatException>().having((e) => e.message, 'message', contains(...))) (such as 'BEGIN PUBLIC KEY', 'single PEM block', 'Invalid SPKI DER', and 'thumbprint').
Details
Impact: Bare throwsFormatException cannot distinguish a regression in SPKI validation or multi-block detection from an unrelated PEM parse failure.
Evidence (Executed): Ed25519PublicJwk.fromPublicKeyPem('-----BEGIN PUBLIC KEY-----\n-----END PUBLIC KEY-----') threw Invalid SPKI DER structure for Ed25519 public key. rather than Expected PEM block.
Line 112 ('-----BEGIN PUBLIC KEY-----\n-----END PUBLIC KEY-----') currently decodes as an empty byte list under package:pem lax mode and throws Invalid SPKI DER structure for Ed25519 public key.. Matching message substrings pins each branch directly.
🤖 Agent-generated
| @@ -0,0 +1,180 @@ | |||
| // Copyright 2026 The Flutter Authors. All rights reserved. | |||
There was a problem hiding this comment.
This duplicates app_dart/lib/src/model/jwks/ed25519_jwk.dart and has already drifted on day 0 (asUnmodifiableView() and simplified ==/hashCode are only here). Keeping dummy_ci/ self-contained for Cloud Run explains the copy, so add a short header comment naming the mirror. Future security or parser fixes to one copy will be missed in the other without an explicit sync note or shared package.
Add a brief file comment noting this mirrors app_dart/lib/src/model/jwks/ed25519_jwk.dart, and backport any fixes from this review (asUnmodifiableView(), ==/hashCode, and boundary checks) to app_dart.
Details
Impact: Future security or parser fixes to one copy will be missed in the other without an explicit sync note or shared package.
Evidence (Read): diff -u app_dart/lib/src/model/jwks/ed25519_jwk.dart dummy_ci/lib/src/model/ed25519_jwk.dart shows identical 180-line files except asUnmodifiableView() (line 116) and simplified ==/hashCode (lines 172-176) exist only in dummy_ci.
Option C: if we do not need single-directory gcloud run deploy --source dummy_ci builds, extract a tiny pure-Dart package (depending only on crypto, meta, and pem) shared by both app_dart and dummy_ci. Otherwise, keep the standalone copy and keep the two files aligned.
🤖 Agent-generated
There was a problem hiding this comment.
I will move it to common place once all stacked PR's for jwks and dummy_ci landed
1fa4682 to
36bdcd3
Compare
2011823 to
1139f52
Compare
Adds the self-contained
Ed25519PublicJwkmodel and SPKI PEM/JWK parser todummy_ci, mirroring Cocoon PR #5196.Summary
collection,crypto,jose_plus, andpemdependencies todummy_ci/pubspec.yamland updatesdummy_ci/pubspec.lock.dummy_ci/lib/src/model/ed25519_jwk.dartwith strict 44-byte RFC 8410 Ed25519 SPKI DER validation, RFC 7638 SHA-256 thumbprintkid, RFC 8037 JWK serialization,toJoseKey(),toPublicKeyPem(), andisValidJwksKeyId().ed25519_jwk.dartfromdummy_ci/lib/dummy_ci.dart.dummy_ci/test/model/ed25519_jwk_test.dartcovering RFC 8037 Appendix A.1/A.3/A.4 and RFC 8410 test vectors,jose_plusEdDSA verification, and malformed SPKI/PEM/kid rejection.Stack
dummy_ciCloud Run app, Dockerfile, and CIEd25519PublicJwkmodel and SPKI PEM/JWK parserCloudKmsService,FakeCloudKmsService, andDummyCiConfigGET /api/v1/jwksendpoint, server wiring, and local dev serverPOST /webhookGET /statusAPI and mockGET /logsendpointPOST /complete-runworker, OIDC auth, Ed25519 KMS signer, and Cocoon callbackTesting
dart pub get,dart format --set-exit-if-changed .,dart analyze --fatal-infos,dart test --test-randomize-ordering-seed=random --reporter expandeddart --enable-asserts analyze.dartanddart run dev/cocoon_code_health/bin/check.dartTowards flutter/flutter#197798