Skip to content

Adding support for HistoryProofV2 #433

Merged
kevinlewi merged 1 commit intofacebook:mainfrom
haochenuw:lookup_history_v2
May 24, 2024
Merged

Adding support for HistoryProofV2 #433
kevinlewi merged 1 commit intofacebook:mainfrom
haochenuw:lookup_history_v2

Conversation

@haochenuw
Copy link
Contributor

The main change in this PR is the introduction of HistoryProofV2 which improves security properties for limited history proofs. It is based upon #422, with changes to maintain backward compatibility and support unit tests for both versions of history proof.

  • Added HistoryProofV2 struct and key_history_v2 and key_history_verify_v2 functions which generates and verifies HistoryProofV2.
  • Extended HistoryVerificationParams to include information about the HistoryParams, to be used during the proof verification.
  • Removes HistoryParams::SinceEpoch. The only way for specifying a non-default parameter now is with HistoryParams::MostRecent.
  • Added a new get_marker_versions() utility function which determines the past and future version numbers to check as part of the HistoryProofV2 generation and verification
  • Moved HistoryParams out from akd and into akd_core since it is also used by verification
  • Added a new InvalidVersion error type
  • Added tests for HistoryProofV2
  • updated docs
  • Bumping the version to 0.12.0-pre.1

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 2, 2024
@haochenuw
Copy link
Contributor Author

@dillonrg -- I saw that Kevin has renamed in PR428 the MostRecent to MostRecentInsecure in HistoryParams. Since I am reusing MostRecent for history V2 as well that created a merge conflict. I have thought there are two options

1/ Rename it back to MostRecent. This is the easiest and since in this PR explicitly mark V1 of HistoryProof as deprecate, it feels like risk of misuse is small.

2/ Leave HistoryParams untouched and add a new struct HistoryParamsV2 (similarly, HistoryVerificationParamsV2). This makes the message clearer but the unit tests macros that I have added in this PR will need to be modified to pass in those structs as parameters.

Let me know what you think and I can make the changes!

cc @kevinlewi for FYI.

@haochenuw
Copy link
Contributor Author

cc @eozturk1 @afterdusk for your thoughts on the choices above.

@haochenuw haochenuw force-pushed the lookup_history_v2 branch 2 times, most recently from ebca97f to afa6d12 Compare May 10, 2024 21:14
@kevinlewi
Copy link
Contributor

@haochenuw Thanks for working on this!

I think, rather than having a key_history() and key_history_v2() interface, it might be better to instead just have one key_history() function, but add an additional parameter that allows the caller to essentially specify the version. Then, the return of the function can be an enum, something like:

pub enum KeyHistoryResult {
  V1(V1Struct),
  V2(V2Struct),
}

which can be parsed by key_history_verify() as well. That way, we also avoid having to throw everything into macros for the tests that test both versions.

Let me know what you think about the suggested change... I am hoping it will lead to a smaller change overall and simpler code.

Also, no need to push each commit to the PR, you can just force-push to erase the history and have a single commit change for the PR.

@haochenuw haochenuw force-pushed the lookup_history_v2 branch 2 times, most recently from 6efeb0c to de7797f Compare May 21, 2024 22:07
@haochenuw haochenuw marked this pull request as draft May 21, 2024 22:22
@haochenuw haochenuw marked this pull request as ready for review May 22, 2024 20:22
Copy link
Contributor

@kevinlewi kevinlewi left a comment

Choose a reason for hiding this comment

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

Fantastic! Some nits in comments but overall LGTM!

@haochenuw haochenuw force-pushed the lookup_history_v2 branch from de7797f to 5fde96a Compare May 24, 2024 16:13
@haochenuw
Copy link
Contributor Author

All comments addressed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants