-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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) |
There was a problem hiding this comment.
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.
This PR addresses Issue #37, implementing the proposed changes. Some notes:
CommitterKey<G{1,2}>
toUniversalParams<G{1,2}>
, and their names changed accordingly fromG{1,2}_COMMITTER_KEY
toG{1,2}_UNIVERSAL_PARAMS
. This has been done to simplify the implementation ofget_g{1,2}_committer_key()
, which internally calls the functionInnerProductArgPC::trim()
, which in turn takes a variable of typeUniversalParams
.load_g_{1,2}_universal_params()
(formerlyload_g_{1,2}_committer_key()
) more than once does leaveG{1,2}_UNIVERSAL_PARAMS
unchanged and returns astd::io::ErrorKind::AlreadyExists
error.load_g_{1,2}_committer_key()
makes unit testing a little bit awkward.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.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 aroundload_g_{1,2}_committer_key()
, which catch (and discard)std::io::ErrorKind::AlreadyExists
errors resulting from multiple invocations ofload_g_{1,2}_committer_key()
. This allows to callset_g_{1,2}_universal_params_for_testing()
wherever needed in tests.