Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl stampler, tek manager, etc #1408

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: impl stampler, tek manager, etc #1408

wants to merge 3 commits into from

Conversation

andysim3d
Copy link
Collaborator

@andysim3d andysim3d commented Mar 4, 2025

Pull Request Checklist


PR-Codex overview

This PR introduces a new Signer Java SDK for handling cryptographic operations, including signing and verification of payloads. It adds essential classes for exception handling, key management, and testing, while updating the project configuration and dependencies.

Detailed summary

  • Added NoTEKException, NoInjectedBundleException, and StamperNotInitializedException classes for error handling.
  • Introduced TEKManager class for managing encryption keys.
  • Created Stamper class for signing payloads.
  • Added StamperTests for unit testing functionality.
  • Updated pom.xml with new dependencies and project metadata.
  • Added build instructions in README.md.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 3:22pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 3:22pm

Copy link

graphite-app bot commented Mar 4, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Collaborator

@moldy530 moldy530 left a comment

Choose a reason for hiding this comment

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

Nice yea this looks good to me mostly. Only feedback is around making sure we can handle the case where someone might want to:

  1. use our code to generate a KeysetHandle for a TEK that they then would store externally
  2. use externally stored TEK to get an instance of the stamper / signer later

* Creates a new TEK via HpkeTEKManager or returns the existing one
* @return TEK public key
*/
public String initTek(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should probably be static. One possible flow is creating a TEK and storing it somewhere, so it could be that this stamper is initialized with a TEK that's externally managed

Comment on lines 115 to 116
this.bundlePrivateKey = Utilities.bytesToHex(privateKeyBytes).toLowerCase(Locale.ROOT).toCharArray();
this.bundlePublicKey = Utilities.bytesToHex(publicKeyBytes).toLowerCase(Locale.ROOT).toCharArray();
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it more convenient / efficient to just skip this conversion and store the keys as byte[] in this class?




byte[] privateKeyBytes = Utilities.HexToBytes(signingKeyHex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah yea here is what I was thinking we could skip if the stamper just stores the keys as bytes

Copy link
Collaborator

@moldy530 moldy530 left a comment

Choose a reason for hiding this comment

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

LGTM with a few comments. will let @mokok123 comment as well

Comment on lines +51 to +53
public Stamper() {
this(/* tekManager= */null);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this a construction flow we want to enable? you kinda always need a TEK manager to make this work.

I think we should have the following in addition to the one above:

public Stamper(targetPrivateKeyHex: String) {}

public Stamper(targetPrivateKey: byte[]) {}

public Stamper(targetKeySet: KeysetHandle) {}

// maybe these too?
public Stamper(targetPrivateKeyHex: String, bundle: String) {}

public Stamper(targetPrivateKey: byte[], bundle: String) {}

public Stamper(targetKeySet: KeysetHandle, bundle: String) {}

public String initTek() throws GeneralSecurityException, InvalidProtocolBufferException {
byte[] tekPublicKeyBytes = this.tekManager.createTEK().getPublicKeyBytes().toByteArray();
return Hex.encode(tekPublicKeyBytes);

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change

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.

2 participants