Pre computations#259
Merged
SteveMaier-IRT merged 27 commits intoElection-Tech-Initiative:mainfrom Apr 18, 2022
Merged
Conversation
…s to encrypt a ballot. There is are two queues in a global (PrecomputedBufferContext) and the queues are populated with a populate method and stopped with a stop_populate method. Then in encryptSelection (encrypt.cpp) if precomputed values are available in the queues then those values are used to generate the encrypted selection.
…/electionguard-cpp into pre-computations
lprichar
approved these changes
Apr 13, 2022
Contributor
lprichar
left a comment
There was a problem hiding this comment.
lg2m. Couple minor comments in the C#. I skimmed over the C++ but don't understand it well enough to feel comfortable commenting. Loved all the comments and small method sizes.
AddressXception
approved these changes
Apr 14, 2022
Contributor
AddressXception
left a comment
There was a problem hiding this comment.
looks great, loving all the test coverage. just left a few questions/comments - most of it is just semantics and style but did want to call out some of the resource acquisition stuff.
…e and Quadruple entries in the queue.
…/electionguard-cpp into pre-computations
…sults checked first
…/electionguard-cpp into pre-computations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Link your PR to an issue
Fixes #240
Description
The first part of the change is to the C++ electionguard library to introduce a couple queues that will store precomputed values. The precomputed values will be used within encryptSelection, which has been changed, to perform the ElGamal encryption as well as computing the Chaum-Pedersen zero knowledge proof. There is a triple queue and a quadruple queue. The population of these queues is performed by calling the populate method on the PrecomputeBufferContext. There is a global that holds the queues. A call to stop_populate stops population of the queues. Changes were also required in ballot.cpp, elgamal.cpp, and chaum_pedersen.cpp in order to make the zero knowledge proof computation uses the precomputed values.
The second part of the change is to the .Net wrappers that add new APIs to start and stop population of the queues. When the start is called it creates a thread which starts the population. The queue size may be passed in to this or if left zero then the queue size of the quadruple queue will populate up to 5000 entries, the triple queue will have twice the number of entries as the triple queue. The stop on the .Net wrapper will stop the populate thread. Note that if the populate thread populates the queues to the specified maximum queue size then the thread will stop on its own, in this case the stop has no bearing.
Testing
Testing has been added to the testing of the C++ APIs for the encryptSelection API that tests the precomputed case. In addition, tests have been added for the APIs added to elgamal.cpp, chaum_pedersen.cpp and ballot.cpp. Benchmarking tests have been added for the new APIs as well, however because there is no way to specify the number of iterations to perform in the benchmark and because with precomputation the APIs take very little time the benchmarking code quickly exhausts the precomputation queues and falls back to not using precomputation. This skews the benchmarking numbers for the precompute cases significantly.