Skip to content

Conversation

strantalis
Copy link
Member

@strantalis strantalis commented Sep 3, 2025

Proposed Changes

The Encapsulate method created circular dependency and provided no functional benefit over the existing Encrypt method. Simplified the interface by keeping only Encrypt which handles all encryption needs.

  • Remove Encapsulate from Encapsulator interface
  • Remove mockEncapsulator.Encapsulate test helper
  • All existing functionality preserved via Export -> Encrypt flow
  • Make sure AsymEncrytion implements Encapsulator

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

…tor interface

The Encapsulate method created circular dependency and provided no
functional benefit over the existing Encrypt method. Simplified the
interface by keeping only Encrypt which handles all encryption needs.

- Remove Encapsulate from Encapsulator interface
- Remove AsymEncryption.Encapsulate implementation
- Remove mockEncapsulator.Encapsulate test helper
- All existing functionality preserved via Export -> Encrypt flow
Copy link
Contributor

@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.

Summary of Changes

Hello @strantalis, 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 refactors the 'ocrypto' package by streamlining the 'Encapsulator' interface. The 'Encapsulate' method, which was identified as redundant and a source of circular dependencies, has been removed. This change simplifies the interface while ensuring that all key encapsulation and encryption needs are met solely by the 'Encrypt' method, maintaining full functionality.

Highlights

  • Interface Simplification: The 'Encapsulate' method has been removed from the 'Encapsulator' interface, as it was redundant and caused circular dependencies.
  • Test Code Cleanup: The corresponding 'Encapsulate' method implementation has been removed from 'mockEncapsulator' in the test suite.
  • Functional Preservation: All existing encryption functionality is preserved by routing through the 'Encrypt' method, ensuring no regression.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.


Old code, tangled mess,Refactor brings clear new path,Simpler, cleaner now.

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.

@strantalis strantalis changed the title refactor(ocrypto): remove redundant Encapsulate method from Encapsula… refactor(ocrypto): remove redundant Encapsulate method from Encapsulator interface Sep 3, 2025
Copy link
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@strantalis strantalis changed the title refactor(ocrypto): remove redundant Encapsulate method from Encapsulator interface refactor: remove redundant Encapsulate method from Encapsulator interface Sep 3, 2025
// Encapsulator enables key encapsulation with a public key
type Encapsulator interface {
// Encapsulate wraps a secret key with the encapsulation key
Encapsulate(dek ProtectedKey) ([]byte, error)
Copy link
Member

Choose a reason for hiding this comment

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

do we use ProtectedKey interface elsewhere? without diving into it, it would seem the interface would be better than a byte[]. I assume from your PR description the ProtectedKey interface is not used and does not add value, then let's remove it too

Copy link
Member Author

Choose a reason for hiding this comment

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

@pflynn-virtru

We have an implementation of a protected key here but it was getting confusing in my mind because export takes an encapsulator and encapsulator takes a protected key.

Export(encapsulator Encapsulator) ([]byte, error)

Encapsulate(dek ProtectedKey) ([]byte, error)

Copy link
Member

Choose a reason for hiding this comment

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

Alternative: deprecate Export
#2676

@strantalis strantalis closed this Sep 11, 2025
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.

3 participants