Skip to content

Tidy up note package - #271

Merged
AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:tidy_note
Aug 5, 2026
Merged

Tidy up note package#271
AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:tidy_note

Conversation

@AlCutter

Copy link
Copy Markdown
Collaborator

This PR tidies up the note package a bit:

  • Move "common" structs and errors into a new note.go file
  • Add/update top-level NewSigner and NewVerifier functions to natively handle ed25519 keys via the local Signer interface which gives access to the associated verifier.

@AlCutter
AlCutter requested a review from mhutchinson July 31, 2026 19:09
@AlCutter
AlCutter requested a review from a team as a code owner July 31, 2026 19:09
@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.12500% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.06%. Comparing base (fa00c16) to head (f7cee89).
⚠️ Report is 183 commits behind head on main.

Files with missing lines Patch % Lines
note/note.go 78.12% 8 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
- Coverage   82.57%   79.06%   -3.51%     
==========================================
  Files           5       10       +5     
  Lines         241      922     +681     
==========================================
+ Hits          199      729     +530     
- Misses         30      106      +76     
- Partials       12       87      +75     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread note/note.go Outdated
}

// NewVerifier returns a verifier for the given key, if the key's algo is known.
func NewVerifier(key string) (note.Verifier, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit, put this next to the Verifier struct?

Comment thread note/note.go
errVerifierAlg = errors.New("unknown verifier algorithm")
errInvalidHash = errors.New("invalid key hash")
errMalformedSig = errors.New("malformed signature")
errSignerHash = errors.New("invalid verifier hash")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"invalid signer hash"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually this is correct as is - the hash is over the verifier key, even when it's being checked as part of creating a new signer. (Also, this is how upstream names it: https://cs.opensource.google/go/x/mod/+/refs/tags/v0.38.0:sumdb/note/note.go;l=335)

Comment thread note/note.go Outdated
case algEd25519:
// We "re-implement" this here so as to be able to return a local Signer instance (as
// opposed to a note.Signer).
// This has the benefit that all signers from this packge carry a Verifier() getter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/packge/package

Comment thread note/note.go
}

s.sign = func(msg []byte) ([]byte, error) {
return ed25519.Sign(key, msg), nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is different than NewSignerForCosignatureV1, this is intentional, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread note/note.go Outdated
switch keyBytes[0] {
case algECDSAWithSHA256:
return NewECDSAVerifier(key)
case algEd25519CosignatureV1, algMLDSA44:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand this code has just been migrated from note/note_verifier.go, so it might be out of scope for this, PR, but do we also need a case algEd25519?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's handled in the default: case (by upstream sumdb/note).
The reason we can do that here (and not in NewSigner) is that we're not trying to widen the note.Verifier interface, only the note.Signer one.

@AlCutter

AlCutter commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Ta, PTAL

Comment thread note/note.go Outdated
@AlCutter
AlCutter merged commit 38e6e69 into transparency-dev:main Aug 5, 2026
14 checks passed
@AlCutter
AlCutter deleted the tidy_note branch August 5, 2026 10:20
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.

5 participants