trees/mirror: Add mirror wire protocol - #8951
Conversation
aarongable
left a comment
There was a problem hiding this comment.
As far as I can tell, the publisher's add-entries flow is going to be:
- compute set of entries it needs to send
- call mirror.Packages to compute start and end of each package
- for each package:
- use a TileReader to get all the entries
- use a HashReader to get the subtree consistency proof
- call mirror.EntryPackage to serialize it
- call mirror.AddEntriesRequest to serialize all of those into the actual request
Something about this feels a little too manual? I totally understand not wanting to pass a TileReader and/or HashReader into these functions so it can look up all the data itself -- that feels a bit messy. But what if AddEntriesRequest took the entries and their proofs directly, instead of requiring the caller to have first called EntryPackage? Maybe that ends up even worse. Worth thinking about, but feel free to ignore.
| if len(entry) > 0xFFFF { | ||
| return nil, fmt.Errorf("entry is %d bytes, want at most %d", len(entry), 0xFFFF) | ||
| } |
There was a problem hiding this comment.
FYI, cryptobyte checks this for us, so we could save a few lines here and below:
https://pkg.go.dev/golang.org/x/crypto/cryptobyte#BuilderContinuation
It is an error to write more bytes to the child than allowed by the reserved length prefix.
Implement the wire protocol specified in the https://c2sp.org/tlog-witness and https://c2sp.org/tlog-mirror.
Closes #8945