← Back to Pull requests

feat(crypto): support native age recipients #1021

Merged
c1-squire-dev[bot] merged 37 files (4087 lines) on Jul 21, 2026 21:37 UTC
View on GitHub
c1-squire-dev[bot] c1-squire-dev[bot] commented on Jul 21, 2026 15:50 UTC
Author

Summary

Upgrade filippo.io/age from v1.2.1 to v1.3.1 and add first-class recipient-based age encryption to Baton credential outputs.

age v1.3 adds native hybrid post-quantum recipients (age1pq1...) alongside its existing X25519 recipients (age1...). This lets callers supply the standard public recipient directly instead of converting it through a JWK/SSH representation.

API

EncryptionConfig gains:

message AgeRecipientConfig {
  string recipient = 1;
}

The field accepts exactly one standard public age recipient. Private identities are never accepted or transported. When selected, the baton/age/v1 provider writes a standard binary age file to EncryptedData.encrypted_bytes and records a SHA-256 fingerprint of the recipient in key_ids.

The provider registry now separates the encryption-only capability from the existing JWK provider's combined encrypt/decrypt/key-generation interface. This keeps the JWK API compatible while avoiding fake decrypt or key-generation methods on the recipient-only provider.

Supported recipients

  • X25519: age1...

  • Hybrid ML-KEM-768/X25519: age1pq1...
  • Parsing and encryption use the upstream age implementation; this PR does not introduce a custom envelope or cryptographic primitive.

    Security behavior

  • Rejects empty, malformed, identity, whitespace-wrapped, and multiline recipient values.

  • Does not echo invalid recipient input in errors, so a mistakenly supplied private identity is not reflected into logs or RPC errors.

  • Returns raw standard age ciphertext rather than a Baton-specific wrapper.

  • Keeps recipient identities entirely outside Baton.
  • Validation

  • go test -tags=baton_lambda_support ./...

  • golangci-lint v2.12.2 run --timeout=3m

  • buf lint

  • buf breaking --against '.git#branch=main'

  • go mod verify

  • vendored-module resolution with -mod=vendor

  • go build ./cmd/baton
  • Tests independently decrypt provider output with upstream age for both X25519 and hybrid post-quantum identities, cover the public EncryptionManager path, provider inference, deterministic key IDs, metadata preservation, and invalid-input redaction.

    Upstream release: https://github.com/FiloSottile/age/releases/tag/v1.3.1

    Diff: 4087 lines (+3739 / -348) across 37 files Reviewer: pquerna Review duration: 347m
    All Vouch review confidence checks passed
    Residual risk 0.34 = Change Risk (0.95) × (1 − Review Confidence (0.64)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.95 · 4087 lines diff across 37 files
    0.95
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.30 · 3 substantive comment(s)
    0.30
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    63%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Shallow Review Depth shallow_review_depth
    0.244
    Sensitive Paths sensitive_paths
    0.095
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    7 items
    kans kans commented on Jul 21, 2026 17:08 UTC
    Contributor

    This looks fine to me. AI says:
    1. Encoding mismatch (medium): age EncryptedData.encrypted_bytes is a raw binary age file; JWK's is base64 text. Consumers must branch on provider. Consider documenting this on EncryptedData in proto/c1/connector/v2/resource.proto (a comment exists only on AgeRecipientConfig).
    2. Implicit key-ID contract (medium): age sets key_ids = [hex(sha256(recipient string))], leaves deprecated key_id empty; JWK sets both to the JWK thumbprint and mirrors it in EncryptionConfig.key_id. Document the derivation in the proto so control planes can correlate. (Canonicalization is safe — non-canonical recipient strings are rejected, verified.)
    3. Dual API divergence (low): GetEncryptionProviderForConfig cannot resolve age configs (even with explicit provider name); only the new GetEncryptorForConfig can. Only in-repo caller was updated, but the old exported API remains a trap for downstream users — consider deprecation comment or making it delegate.

    c1-squire-dev[bot] c1-squire-dev[bot] commented on Jul 21, 2026 19:23 UTC
    Author

    Addressed all three points in 73258ad1:

    1. Encoding contract: EncryptedData.encrypted_bytes now documents that ciphertext encoding is provider-specific: baton/jwk/v1 emits standard-base64 text and baton/age/v1 emits a standard binary age file. Consumers must dispatch on provider; schema describes plaintext semantics after decryption.
    2. Key-ID contract: key_ids is documented as provider-specific correlation metadata. AgeRecipientConfig now specifies lowercase_hex(SHA-256(UTF-8(canonical recipient))), and the test explicitly proves deprecated key_id stays empty.
    3. Resolver capability split: GetEncryptionProviderForConfig is now deprecated for encryption selection in favor of GetEncryptorForConfig. I did not make it delegate for age because its return interface also requires Decrypt and GenerateKey; doing so would require fake/failing operations or a breaking return-type change. A regression test locks the intended compatibility boundary: JWK resolves through both APIs; age resolves through the encryption-only API.

    Validation on the updated head:

  • go test ./pkg/crypto/...

  • go test -tags=baton_lambda_support ./...

  • golangci-lint v2.12.2 run --timeout=3m

  • buf lint

  • buf breaking --against .git#branch=main

  • go mod verify

  • go build ./cmd/baton
  • All pass.

    pquerna pquerna approved these changes on Jul 21, 2026 19:25 UTC
    Approved Reviewer

    Approved these changes.

    pquerna pquerna approved these changes on Jul 21, 2026 19:27 UTC
    Approved Reviewer

    Approved these changes.

    github-actions[bot] github-actions[bot] commented on Jul 21, 2026 19:30 UTC
    Bot

    General PR Review: feat(crypto): support native age recipients

    Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
    Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 482c7804bcfa.
    Review mode: full
    View review run: https://github.com/ConductorOne/baton-sdk/actions/runs/29861257083

    Review Summary
    Reviewed the full PR diff for security and correctness, focusing on SDK compatibility surfaces (proto/wire, exported Go APIs, serialized state, defaults, dependencies). This adds a baton/age/v1 recipient-only encryption provider and a new EncryptionConfig.age_recipient_config oneof field (number 101), upgrading filippo.io/age v1.2.1 to v1.3.1. The proto change is additive (no field renumbering or reuse), all three generated files (resource.pb.go, resource.pb.validate.go, resource_protoopaque.pb.go) are regenerated and consistent with the source, the new Encryptor interface is additive and leaves the EncryptionProvider method set unchanged, and the EncryptionManager.Encrypt switch to GetEncryptorForConfig strictly widens provider resolution without regressing existing JWK callers. Recipient validation rejects empty, whitespace, multiline, and private-identity input and does not echo the input in errors; dependency changes (filippo.io/hpke indirect, CCTV test vectors) match the age upgrade. No new issues found.

    Security Issues: None found.

    Correctness Issues: None found.

    Suggestions: None.

    github-actions[bot] github-actions[bot] commented on Jul 21, 2026 19:32 UTC
    Reviewer

    No blocking issues found.

    Reviewers
    Assignees
    c1-squire-dev[bot] c1-squire-dev[bot]
    Labels
    risk: low confidence: 63.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 94.7% (HIGH) · Higher = larger blast radius
    94.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 63.8% · Lower = rushed or shallow review
    63.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 34.3% · Safe to merge
    34.3%