Skip to content

Pre computations#259

Merged
SteveMaier-IRT merged 27 commits intoElection-Tech-Initiative:mainfrom
jeffspel-crypto:pre-computations
Apr 18, 2022
Merged

Pre computations#259
SteveMaier-IRT merged 27 commits intoElection-Tech-Initiative:mainfrom
jeffspel-crypto:pre-computations

Conversation

@jeffspel-crypto
Copy link
Copy Markdown
Contributor

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.

@ghost
Copy link
Copy Markdown

ghost commented Apr 13, 2022

CLA assistant check
All CLA requirements met.

Copy link
Copy Markdown
Contributor

@lprichar lprichar left a comment

Choose a reason for hiding this comment

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

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.

Comment thread bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/PrecomputeAPI.cs Outdated
Copy link
Copy Markdown
Contributor

@AddressXception AddressXception left a comment

Choose a reason for hiding this comment

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

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.

Comment thread include/electionguard/precompute_buffers.hpp
Comment thread src/electionguard/precompute_buffers.cpp Outdated
Comment thread src/electionguard/precompute_buffers.cpp Outdated
Comment thread src/electionguard/precompute_buffers.cpp Outdated
Comment thread src/electionguard/precompute_buffers.cpp Outdated
Comment thread include/electionguard/precompute_buffers.hpp Outdated
@SteveMaier-IRT SteveMaier-IRT merged commit 7b68151 into Election-Tech-Initiative:main Apr 18, 2022
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.

🏎 Pre-Encryption Buffer of Exponentiations

5 participants