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

Root hash signature verification v2 #634

Merged
merged 46 commits into from
May 9, 2023

Conversation

tnytown
Copy link
Collaborator

@tnytown tnytown commented Apr 26, 2023

Now with Signed Note verification!

Thanks to @jleightcap for doing all of the work! I'm just here to push it over the finish line :)

Supersedes #527.
Fixes #248.

jleightcap and others added 16 commits April 17, 2023 14:15
Signed-off-by: Jack Leightcap <[email protected]>

TASK(jl): `checkpoint` breakout

Signed-off-by: Jack Leightcap <[email protected]>
Signed-off-by: Jack Leightcap <[email protected]>
Signed-off-by: Jack Leightcap <[email protected]>
Signed-off-by: Jack Leightcap <[email protected]>
The canonical implementation [0] passes the message, message digest, and
public key into their verification method. Our verification method only
takes data and the public key. If we pass the message digest in as the
data, it fails, but if we pass the message in as the data, it succeeds.

[0] https://github.com/sigstore/rekor/blob/4b1fa6661cc6dfbc844b4c6ed9b1f44e7c5ae1c0/pkg/util/signed_note.go#L75

Signed-off-by: Andrew Pan <[email protected]>
Signed-off-by: Andrew Pan <[email protected]>
@@ -133,3 +135,34 @@ def verify_merkle_inclusion(entry: LogEntry) -> None:
f"Inclusion proof contains invalid root hash: expected {inclusion_proof}, calculated "
f"{calc_hash}"
)


def verify_checkpoint(client: RekorClient, entry: LogEntry) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

The location of this function was determined only by the fact that it's called immediately proceeding the Merkle tree verification done above; not because of any real connection to Merkle trees. IMO having this in merkle.py isn't super clear as a result...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha, I'll move it to _internal.rekor.checkpoint

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for picking this up @tnytown 😄 I had some detritus around my local branch that seems cleaned up by your un-borking commit.

This PR was largely stuck by what's pointed out by @woodruffw here: #527 (comment)

I couldn't get the signature to pass and really didn't have the debugging know-how to approach why that might be.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for picking this up @tnytown 😄

Yep, of course!

I couldn't get the signature to pass and really didn't have the debugging know-how to approach why that might be.

I think I was able to fix this with 43b968b. You were really close, the Go impl's signature verification API needs a digest of the data but ours needs the data itself. Just needed a fresh set of eyes :)

@woodruffw woodruffw added this to the 2.0 milestone Apr 26, 2023
woodruffw
woodruffw previously approved these changes Apr 27, 2023
Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

This LGTM, but I'd appreciate a review from @asraa or @haydentherapper if either of you has the time!

In particular: we now verify the signature that comes with the checkpoint and cross-check the signed data (i.e. the root hash) against the inclusion proof's. We do this in two circumstances:

  1. Whenever we're doing online verification (the default)
  2. During offline verification, if the input bundle contains an inclusion proof (including a checkpoint)

@haydentherapper
Copy link
Contributor

Ack, will take a look tomorrow!

@haydentherapper
Copy link
Contributor

Sorry, had a busy week! Will look first thing Monday.

@woodruffw
Copy link
Member

No problem at all! And please let us know if we can do anything to help with review as well 🙂

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.

Looks really great! Just a couple small questions.

@di
Copy link
Member

di commented May 2, 2023

Just a couple small questions.

@haydentherapper Doesn't look like your questions made it into your review, FYI.

sigstore/verify/models.py Outdated Show resolved Hide resolved
sigstore/verify/verifier.py Show resolved Hide resolved
This better reflects the field's intent, rather than
an internal fact about its structure.

Signed-off-by: William Woodruff <[email protected]>
Always perform the inclusion proof opportunistically,
even if the proof it provides is no stronger than
the inclusion promise.

Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
woodruffw
woodruffw previously approved these changes May 9, 2023
Can't use this here yet.

Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw self-assigned this May 9, 2023
@woodruffw woodruffw added enhancement New feature or request component:verification Core verification functionality component:api Public APIs labels May 9, 2023
@woodruffw woodruffw enabled auto-merge (squash) May 9, 2023 17:48
@woodruffw woodruffw merged commit 36b3086 into sigstore:main May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:api Public APIs component:verification Core verification functionality enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include Root Hash verification when verifying a Rekor Inclusion Proof
6 participants