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: accept checkpoint v2 for verifiers #36

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions massifs/massifcontextverified.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,28 @@ func (mc *MassifContext) verifyContext(
return nil, err
}

if state.Version == int(MMRStateVersion1) {
return mc.verifyContextV1(msg, state, options)
switch state.Version {
case int(MMRStateVersion1):
fallthrough
case int(MMRStateVersion2):
return mc.verifyContextV1V2(msg, state, options)
case int(MMRStateVersion0):
return mc.verifyContextV0(msg, state, options)
}
return mc.verifyContextV0(msg, state, options)
return nil, fmt.Errorf("unsupported MMR state version %d", state.Version)

}

func (mc *MassifContext) verifyContextV1(
func (mc *MassifContext) verifyContextV1V2(
msg *cose.CoseSign1Message, state MMRState, options ReaderOptions,
) (*VerifiedContext, error) {
var ok bool
var err error
var peaksB [][]byte

if state.Version != int(MMRStateVersion1) {
// There is no difference between v1 and v2 for the purposes of verification.
// We just need to accept both here.
if state.Version != int(MMRStateVersion1) && state.Version != int(MMRStateVersion2) {
return nil, fmt.Errorf("unsupported MMR state version %d", state.Version)
}

Expand Down