FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Store Public Keys in tiles coordinate-matched to Entry tiles. by ezekiel · Pull Request #8958 · letsencrypt/boulder · GitHub

Store Public Keys in tiles coordinate-matched to Entry tiles. - #8958

Open
ezekiel wants to merge 13 commits into
mainfrom
ezekiel/pubkeys-as-tiles
Open

Store Public Keys in tiles coordinate-matched to Entry tiles.#8958
ezekiel wants to merge 13 commits into
mainfrom
ezekiel/pubkeys-as-tiles

Conversation

ezekiel commented Aug 19, 2026
edited
Loading

Copy link
Copy Markdown
Member

This changes the MTCA to include the public key in the pendingEntries submitted for sequencing. Upon sequencing, the subjectPublicKeyInfo structure is bundled just like Entries are bundled, and stored in tiles with the same coordinates as the Entry tiles, but at a different layer (-2).

For writing the public key tiles, we introduce Bundling and Marshaling functions specific to a new MTCPublicKey structure which wraps subjectPublicKeyInfo and facilitates null pubkey placeholders in the tile information tracked in the Frontier.

Fixes #8913

ezekiel changed the title Store corresponding Public Keys when Entries are appended to Tiles. Store Public Keys in tiles coordinate-matched to Entry tiles. Aug 19, 2026
ezekiel self-assigned this Aug 20, 2026
ezekiel marked this pull request as ready for review August 21, 2026 16:00
ezekiel requested a review from a team as a code owner August 21, 2026 16:00
ezekiel requested a review from jsha August 21, 2026 16:00
Comment thread mtca/mtca.go Outdated
Comment thread trees/tiles/tiles.go Outdated
Comment thread trees/tiles/tiles.go Outdated
Comment thread trees/tiles/tiles.go Outdated
Comment thread trees/tiles/tiles.go
Comment thread trees/pubkey/pubkey.go Outdated
Comment thread trees/pubkey/pubkey.go Outdated
Comment thread trees/pubkey/pubkey.go
Comment thread trees/pubkey/pubkey.go Outdated
Comment thread trees/pubkey/pubkey.go Outdated
ezekiel requested a review from aarongable August 24, 2026 16:03
aarongable previously approved these changes Aug 24, 2026
Comment thread trees/pubkey/pubkey.go Outdated
Co-authored-by: Aaron Gable <aaron@letsencrypt.org>
aarongable previously approved these changes Aug 24, 2026
Comment thread trees/pubkey/pubkey.go
)

const typeNilPubkey = 0
const typeMTCPubkey = 1

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit: the outer type is MTCPublicKey. The inner type represented by this constant is SubjectPublicKeyInfo.

Suggested change
const typeMTCPubkey = 1
const typeSPKI = 1

Comment thread trees/pubkey/pubkey.go
const typeNilPubkey = 0
const typeMTCPubkey = 1

type MTCPublicKey struct {

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Needs a doccomment. I notice below that "Marshal returns the encoding of its receiver." That's also what MTCLogEntry.Marshal says; but type MTCLogEntry defines what its encoding is (by reference to the spec). Since MTCPublicKey is our own local data type we should define its encoding. Ideally in the type MTCPublicKey doccomment. Also this doccomment should mention briefly that this is a local data type, not defined in the MTC spec.

Comment thread trees/pubkey/pubkey.go
Comment on lines +39 to +40
// Pubkey returns the subjectPublicKeyInfo structure bytes of an MTCPublicKey if
// type is typeMTCPubkey, or 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
// Pubkey returns the subjectPublicKeyInfo structure bytes of an MTCPublicKey if
// type is typeMTCPubkey, or nil
// Pubkey returns the subjectPublicKeyInfo structure bytes of an MTCPublicKey if
// its type is typeMTCPubkey, otherwise nil.

Comment thread trees/pubkey/pubkey.go

switch mtcpk.typ {
case typeMTCPubkey:
// pkBytes is a crypto.x509 SubjectPublicKeyInfo structure

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
// pkBytes is a crypto.x509 SubjectPublicKeyInfo structure
// pkBytes is an RFC 5280 SubjectPublicKeyInfo structure

(there's no type SubjectPublicKeyInfo in crypto/x509).

Comment thread trees/pubkey/pubkey.go
"golang.org/x/crypto/cryptobyte"
)

const typeNilPubkey = 0

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Here you use nil (Go idiom); elsewhere you use null (matching how MTC names its null_entry). Let's do this: for the encoded data, let's follow MTC practice and call this typeNullPubkey. Let's reserve nil for when we are talking about a Go value that holds nil. I think that just means renaming this const; in the rest of the code you already use null.

Comment thread trees/pubkey/pubkey.go
}

// BundleReader reads records of MTCPubkey from the underlying buffer in the
// pubkey bundle format.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We should define "pubkey bundle format" somewhere. Maybe in a package doccomment?

Comment on lines +15 to +16
// Broad scope var with pubkey Bytes for use in tests
var testPubkeyBytes []byte

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We should avoid global vars when possible, even in tests. They can create hard-to-debug interactions between test cases, and can prevent setting test cases to t.Parallel(). I know there are some examples to the contrary in the code base, particularly in the RA tests.

I think we can improve things in these tests by having testPubkeySingleton simply generate the key from scratch each time. Same for the other ...Singleton functions. And in the process we should rename them to remove Singleton from the name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Generating the key each time slows down tests quite a lot because tile_test has some tests that write 65k tiles.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah, that makes sense. Three possible solutions:

  • Generate a key once per test case, and pass it down into the helper functions.
  • Continue to use one global test key, but initialize it in init() and subsequently only read it (avoiding race conditions). In this case I'd also want to document that the tests don't rely on key equality.
  • In the helpers, put in a syntactically valid but not "real" key.

I think I prefer the last one. tiles_test isn't testing marshaling/unmarshaling of type MTCPublicKey, so it doesn't need to exercise that code with a real key. You actually did this in tiles_test.go line 580:

		err := f.AppendEntry(&entry.MTCLogEntry{}, &pubkey.MTCPublicKey{})

I suspect the other tests needed a more realistic key because of the ParsePKIXPublicKey() call that I suggested removing.

aarongable Aug 27, 2026
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note that &pubkey.MTCPublicKey{} isn't actually an invalid entry / fake key: it's the null entry used at index 0. To exercise the "load some bytes" code path, it would need to be something more like &pubkey.MTCPublicKey{typ: typeMTCPubkey, pub: []byte("hello world")}. Otherwise I totally agree: all of the real keys in these tests were necessary when this code was calling x509.ParsePKIXPublicKey on every one of them, but we've simplified that out now.

Comment thread trees/tiles/tiles.go

if f.entryTile.coords.W == 256 {
// Tile is full. Queue it for writing.
// Entry Tile is full. Queue it for writing.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
// Entry Tile is full. Queue it for writing.
// Entry tile is full. Queue it for writing.

Comment thread trees/tiles/tiles.go
},
data: nil,
}
// Pubkey Tile is full. Queue it for writing.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
// Pubkey Tile is full. Queue it for writing.
// Pubkey tile is full. Queue it for writing.

Comment thread trees/tiles/tiles_test.go
Comment on lines +90 to +91
// the Subject Public Key Information structure of the same key we can use and re-use
var testPubkeySingletonSPKI crypto.PublicKey

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Here's another place where we should generate key within each test case (possibly by calling a helper function) rather than having a singleton.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

tiles: store pubkeys as a tile layer

3 participants


Back | FazBrowse Home | New Git URL