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: add verification functions #986

Merged
merged 5 commits into from Aug 30, 2022
Merged

Conversation

asraa
Copy link
Contributor

@asraa asraa commented Aug 18, 2022

Signed-off-by: Asra Ali asraa@google.com

Summary

  • Adds verification functions for inclusion proof, root hash, consistency, and full entry

Release Note

Documentation

Fixes #891
Fixes #789

Creating follow-up issue for the TUF usage. Contingent on sigstore/sigstore#500 which I'll go back to today.

@asraa asraa requested a review from a team as a code owner August 18, 2022 17:42
@asraa asraa force-pushed the verification-funcs branch 3 times, most recently from 970fc7f to a8c575c Compare August 18, 2022 18:41
pkg/verify/verify.go Outdated Show resolved Hide resolved
pkg/verify/verify.go Outdated Show resolved Hide resolved
pkg/verify/verify.go Show resolved Hide resolved
pkg/verify/verify.go Outdated Show resolved Hide resolved
pkg/verify/verify.go Outdated Show resolved Hide resolved
@priyawadhwa
Copy link
Contributor

Hey @asraa is this ready for review?

@asraa
Copy link
Contributor Author

asraa commented Aug 29, 2022

Reviewing now! sorry about that, was out for a few

Signed-off-by: Asra Ali <asraa@google.com>

lint and comment

Signed-off-by: Asra Ali <asraa@google.com>

update

Signed-off-by: Asra Ali <asraa@google.com>

remove more code

Signed-off-by: Asra Ali <asraa@google.com>

fix

Signed-off-by: Asra Ali <asraa@google.com>

comments

Signed-off-by: Asra Ali <asraa@google.com>

fix

Signed-off-by: Asra Ali <asraa@google.com>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Will you be adding tests?

)

// ProveConsistency verifies consistency between an initial, trusted STH
// and a second new STH. Assumes that the signature on the STHs' are verified.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it'd be better to check the signatures on the STHs, this seems like something that'd be easy to skip as a client. Same with VerifyCurrentCheckpoint - It verifies the newest checkpoint, but not the previous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous/old one should already be trusted in VerifyCurrentCheckpoint, but I can add for rigor

Copy link
Contributor Author

@asraa asraa Aug 29, 2022

Choose a reason for hiding this comment

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

Note that for that, we would need to pass in the verifier. I think including this in the doc string is fine? ProveConsistency would mean prove consistency, not verify tree head? wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I'm ok with that. An example somewhere of a few different ways of composing these functions might be useful

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed, examples to be added elsewhere.

}

// VerifyInclusion verifies an entry's inclusion proof. Clients MUST also
// verify the root hash via VerifyRootHash.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: VerifyRootHash is the old function name

Nonetheless, a consistency proof is effectively an inclusion proof for each checkpoint, correct? So just checking consistency would be sufficient if you have a previous checkpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm confused about the statement "consistency proof is effectively an inclusion proof for each checkpoint".

I'll update the comment

 Clients MUST either verify
// the root hash against a new STH (via VerifyCurrentCheckpoint) or against a
// trusted, existing STH (via ProveConsistency).

Copy link
Contributor

Choose a reason for hiding this comment

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

Chatted offline, I was incorrect cause I was missing the context on a comment on a doc.

The comment SG. Should we note that if you verify against the current checkpoint, the inclusion proof should have been one that's been persisted and is trusted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

against the current checkpoint? then wouldn't you persist the new one?

i think that's usage / client storage is out of scope here

Copy link
Contributor

Choose a reason for hiding this comment

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

I was asking when you'd use VerifyInclusion then VerifyCurrentCheckpoint. What is the use case? You're right that you'd just persist the new one, so I guess my point is that you'd probably only call ProveConsistency after VerifyInclusion

Copy link
Contributor

Choose a reason for hiding this comment

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

Like the above comment, I think we should document the examples for various use cases to make it clear when these are to be used.

  • A witness verifying from a previous checkpoint - VerifyCurrentCheckpoint
  • Verifying an SET - VerifyLogEntry
  • Verifying an inclusion proof - (I think) VerifyInclusion and ProveConsistency
  • Verifying an inclusion proof offline - Just VerifyInclusion (and verifying STH signature, which isn't a function currently)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be in a documentation file. Documentation in code would only be understood anyway from code examples.

@asraa
Copy link
Contributor Author

asraa commented Aug 29, 2022

Will you be adding tests?

I do have some local tests that I haven't committed yet: the trillian/merkle libs don't expose an easy way to generate proofs, so I'd have to hard-code some examples.

Signed-off-by: Asra Ali <asraa@google.com>
@asraa
Copy link
Contributor Author

asraa commented Aug 29, 2022

@haydentherapper added tests, didn't test things that were trivial and already tested in other APIs. feel free to add more

Signed-off-by: Asra Ali <asraa@google.com>

update

Signed-off-by: Asra Ali <asraa@google.com>
priyawadhwa
priyawadhwa previously approved these changes Aug 29, 2022
Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

lgtm!

Signed-off-by: Asra Ali <asraa@google.com>

fix

Signed-off-by: Asra Ali <asraa@google.com>
@asraa
Copy link
Contributor Author

asraa commented Aug 30, 2022

@priyawadhwa @bobcallaway sorry, could I get one more look on this?

Signed-off-by: Asra Ali <asraa@google.com>
Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

nice!

@asraa asraa merged commit 5159d01 into sigstore:main Aug 30, 2022
@github-actions github-actions bot added this to the v1.0.0 milestone Aug 30, 2022
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.

Improvements to rekor-cli verify command Expose Go function for validating log entry
4 participants