Skip to content

trees/cosigned: Add cosigned.Message#8819

Merged
aarongable merged 4 commits into
mainfrom
cosignedmessage
Jun 30, 2026
Merged

trees/cosigned: Add cosigned.Message#8819
aarongable merged 4 commits into
mainfrom
cosignedmessage

Conversation

@jsha

@jsha jsha commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Part of #8818

@jsha jsha marked this pull request as ready for review June 22, 2026 16:47
@jsha jsha requested a review from a team as a code owner June 22, 2026 16:47
@jsha jsha requested a review from aarongable June 22, 2026 16:47
Comment thread trees/cosigned/message.go
LogOrigin string
Start uint64
End uint64
SubtreeHash [sha256.Size]byte

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe we'll be using tlog.Hash throughout trees so we should use it here to avoid unnecessary conversions.

Suggested change
SubtreeHash [sha256.Size]byte
SubtreeHash tlog.Hash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, but it feels weird to pull in all of tlog in this PR just for an alias type. How about keeping [sha256.Size]byte in this PR, pulling in tlog as a new dependency in #8808 (which uses tlog in earnest), and then bumping this to use the alias type as a followup?

Comment thread trees/cosigned/message_test.go
Comment thread trees/cosigned/message.go

@aarongable aarongable left a comment

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.

LGTM with one API question.

Comment thread trees/cosigned/message.go Outdated
}

// Unmarshal unmarshals the input bytes into its receiver.
func (message *Message) Unmarshal(input []byte) 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.

I know that the UnmarshalJSON interface requires a pointer receiver so that it can modify its receiver, but that's because it's an interface and therefore has to be a method.

As far as I know, we're not trying to have this method match anyone's interface. Is there a particular reason to require that users write

cm := new(cosigned.Message)
err := cm.Unmarshal(input)

instead of

cm, err := cosigned.Parse(input)

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No particular API design reason; really only naming cuteness. I'm happy with cosigned.Parse(), though I think I'll write it as cosigned.Unmarshal() to match the existing Marshal() in this package and the Go common usage (e.g. encoding/asn1 also uses Marshal/Unmarshal).

@beautifulentropy beautifulentropy changed the title mtc/cosigned: add cosigned.Message trees/cosigned: Add cosigned.Message Jun 30, 2026
@aarongable aarongable merged commit aa99d7c into main Jun 30, 2026
19 checks passed
@aarongable aarongable deleted the cosignedmessage branch June 30, 2026 23:38
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.

3 participants