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

Improve logic of dlog committer key generation, retrieval and trimming #38

Merged
merged 6 commits into from
Feb 4, 2022

Conversation

lgiussan
Copy link
Contributor

This PR addresses Issue #37, implementing the proposed changes. Some notes:

  • The type of the static variables holding the dlog committer keys has been changed from CommitterKey<G{1,2}> to UniversalParams<G{1,2}>, and their names changed accordingly from G{1,2}_COMMITTER_KEY to G{1,2}_UNIVERSAL_PARAMS. This has been done to simplify the implementation of get_g{1,2}_committer_key(), which internally calls the function InnerProductArgPC::trim(), which in turn takes a variable of type UniversalParams.
  • Calling load_g_{1,2}_universal_params() (formerly load_g_{1,2}_committer_key()) more than once does leave G{1,2}_UNIVERSAL_PARAMS unchanged and returns a std::io::ErrorKind::AlreadyExists error.
  • The change in the semantics of load_g_{1,2}_committer_key() makes unit testing a little bit awkward.
    • On the one hand it is not possible to call load_g_{1,2}_committer_key() only once in unit tests, because we do not know a priori the order in which tests are run, and moreover this would require always running tests in batch.
    • On the other hand, calling load_g_{1,2}_committer_key() more than once generates an error.
      To solve this problem the two functions set_g_{1,2}_universal_params_for_testing() have been introduced: they are simple wrappers around load_g_{1,2}_committer_key(), which catch (and discard) std::io::ErrorKind::AlreadyExists errors resulting from multiple invocations of load_g_{1,2}_committer_key(). This allows to call set_g_{1,2}_universal_params_for_testing() wherever needed in tests.

cctp_primitives/src/proving_system/init.rs Outdated Show resolved Hide resolved
cctp_primitives/src/proving_system/init.rs Outdated Show resolved Hide resolved
cctp_primitives/src/proving_system/init.rs Outdated Show resolved Hide resolved
let supported_degree =
supported_degree.unwrap_or_else(|| pp_g1_guard.as_ref().unwrap().max_degree());
let (ck, _) =
InnerProductArgPC::<_, Digest>::trim(&pp_g1_guard.as_ref().unwrap(), supported_degree)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note for the future: this approach is fine but everytime we trim we do a copy of the generators. Currently the generators, in the CommiterKey struct is a Vec, maybe we can do better by defining them as a slice with some lifetime. For sure this is not a change to be performed here.

cctp_primitives/src/proving_system/init.rs Outdated Show resolved Hide resolved
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.

Improve load_g_{1,2}_committer_key() and get_g_{1,2}_committer_key() logic
3 participants