Skip to content

Commit

Permalink
return sth
Browse files Browse the repository at this point in the history
Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa committed Aug 30, 2022
1 parent 8de1bf6 commit 3a6c523
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/verify/verify.go
Expand Up @@ -77,32 +77,35 @@ func ProveConsistency(ctx context.Context, rClient *client.Rekor,
// against a newly fetched Checkpoint.
//nolint
func VerifyCurrentCheckpoint(ctx context.Context, rClient *client.Rekor, verifier signature.Verifier,
oldSTH *util.SignedCheckpoint) error {
oldSTH *util.SignedCheckpoint) (*util.SignedCheckpoint, error) {
// The oldSTH should already be verified, but check for robustness.
if !oldSTH.Verify(verifier) {
return errors.New("signature on old tree head did not verify")
return nil, errors.New("signature on old tree head did not verify")
}

// Get and verify against the current STH.
infoParams := tlog.NewGetLogInfoParamsWithContext(ctx)
result, err := rClient.Tlog.GetLogInfo(infoParams)
if err != nil {
return err
return nil, err
}

logInfo := result.GetPayload()
sth := util.SignedCheckpoint{}
if err := sth.UnmarshalText([]byte(*logInfo.SignedTreeHead)); err != nil {
return err
return nil, err
}

// Verify the signature on the SignedCheckpoint.
if !sth.Verify(verifier) {
return errors.New("signature on tree head did not verify")
return nil, errors.New("signature on tree head did not verify")
}

// Now verify consistency up to the STH.
return ProveConsistency(ctx, rClient, oldSTH, &sth, *logInfo.TreeID)
if err := ProveConsistency(ctx, rClient, oldSTH, &sth, *logInfo.TreeID); err != nil {
return nil, err
}
return &sth, nil
}

// VerifyInclusion verifies an entry's inclusion proof. Clients MUST either verify
Expand Down

0 comments on commit 3a6c523

Please sign in to comment.