Skip to content

Switch to go1.26 crypto/hpke#63

Merged
rthellend merged 2 commits intomainfrom
go1.26-hpke
Feb 14, 2026
Merged

Switch to go1.26 crypto/hpke#63
rthellend merged 2 commits intomainfrom
go1.26-hpke

Conversation

@rthellend
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @rthellend, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the project's cryptographic operations by transitioning from a custom HPKE implementation to the official crypto/hpke package introduced in Go 1.26. This change enhances maintainability, security, and leverages the Go standard library's robust and well-tested cryptographic primitives. The update also involves bumping the required Go version and cleaning up obsolete internal HPKE-related files.

Highlights

  • HPKE Implementation Migration: The project has migrated its HPKE (Hybrid Public Key Encryption) implementation from a custom internal package to the standard crypto/hpke package available in Go 1.26.
  • Go Version Update: The Go module has been updated to require Go 1.26.0, aligning with the availability of the new crypto/hpke package.
  • Dependency Updates and Cleanup: The golang.org/x/crypto dependency has been updated to a newer version, and the previously used internal HPKE package and its related files have been removed.
  • API Adaptation: Code interacting with HPKE, including setup for both sender and recipient, has been refactored to use the new standard library API, including hpke.NewRecipient, hpke.NewSender, and specific KEM/AEAD identifiers.
Changelog
  • ech.go
    • Added crypto/ecdh and crypto/hpke imports for standard library cryptography.
    • Removed the import for the internal HPKE package.
    • Corrected a typo in the hpkeCtx field type from hpke.Receipient to hpke.Recipient.
    • Updated HPKE recipient setup logic to use ecdh.X25519().NewPrivateKey, hpke.NewDHKEMPrivateKey, hpke.NewKDF, hpke.NewAEAD, and hpke.NewRecipient from the standard library.
  • ech_test.go
    • Added crypto/hpke import for standard library HPKE functions.
    • Removed the import for the internal HPKE package.
    • Updated HPKE sender setup in tests to use hpke.NewDHKEMPublicKey, hpke.NewSender, hpke.HKDFSHA256(), and hpke.ChaCha20Poly1305() from the standard library.
  • go.mod
    • Updated the required Go version from 1.24 to 1.26.0.
    • Updated the golang.org/x/crypto dependency from v0.40.0 to v0.48.0.
    • Cleaned up indirect dependencies.
  • go.sum
    • Updated checksums for golang.org/x/crypto and golang.org/x/sys to reflect the new versions.
  • helpers_test.go
    • Added crypto/hpke import for standard library HPKE functions.
    • Removed the import for the internal HPKE package.
    • Updated AEAD constants to use hpke.ChaCha20Poly1305(), hpke.AES128GCM(), and hpke.AES256GCM() from the standard library.
    • Refactored HPKE sender setup to use hpke.NewDHKEMPublicKey, hpke.NewSender, hpke.HKDFSHA256(), and aead.ID().
  • internal/hpke/LICENSE
    • Removed the license file for the internal HPKE package.
  • internal/hpke/README.txt
    • Removed the README file for the internal HPKE package.
  • internal/hpke/hpke.go
    • Removed the custom HPKE implementation file.
  • internal/hpke/hpke_test.go
    • Removed the test file for the custom HPKE implementation.
  • internal/hpke/internal/byteorder/byteorder.go
    • Removed the internal byte order utility file.
  • internal/hpke/internal/fips140/hkdf/hkdf.go
    • Removed the internal HKDF implementation file.
  • internal/hpke/testdata/rfc9180-vectors.json
    • Removed the test vectors for the custom HPKE implementation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement, migrating from an internal/vendored HPKE implementation to the one provided in Go 1.26. The changes simplify the codebase and leverage the standard library. The API migrations and dependency updates seem correct. I've identified one bug related to handling multiple ECH keys that could lead to decryption failures, and another opportunity to improve the logic by exiting a loop early after a successful operation. Please see my detailed comments.

@rthellend rthellend merged commit 286a043 into main Feb 14, 2026
4 checks passed
@rthellend rthellend deleted the go1.26-hpke branch February 14, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant