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

Adding support for HistoryProofV2 #433

Merged
merged 1 commit into from
May 24, 2024

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.

README.md Outdated Show resolved Hide resolved
akd/benches/directory.rs Show resolved Hide resolved
akd/src/append_only_zks.rs Show resolved Hide resolved
akd_core/src/build.rs Outdated Show resolved Hide resolved
akd/src/directory.rs Outdated Show resolved Hide resolved
akd/src/directory.rs Outdated Show resolved Hide resolved
akd/src/directory.rs Outdated Show resolved Hide resolved
akd_core/src/build.rs Outdated Show resolved Hide resolved
akd_core/src/utils.rs Outdated Show resolved Hide resolved
akd_core/src/verify/history.rs Outdated Show resolved Hide resolved
akd_core/src/verify/history.rs Outdated Show resolved Hide resolved
akd_core/src/verify/history.rs Outdated Show resolved Hide resolved
akd/src/append_only_zks.rs Show resolved Hide resolved
akd/src/utils.rs Outdated Show resolved Hide resolved
@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!

akd/src/append_only_zks.rs Show resolved Hide resolved
akd/src/append_only_zks.rs Show resolved Hide resolved
examples/src/fixture_generator/reader/mod.rs Show resolved Hide resolved
examples/src/mysql_demo/mysql_storables.rs Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
akd_core/src/utils.rs Show resolved Hide resolved
@haochenuw
Copy link
Contributor Author

All comments addressed. Closing.

@haochenuw haochenuw closed this May 24, 2024
@haochenuw haochenuw reopened this May 24, 2024
@kevinlewi kevinlewi merged commit 6998ca6 into facebook:main May 24, 2024
27 checks passed
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