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

Feature/range proof #366

Merged
merged 96 commits into from
Aug 2, 2023
Merged

Conversation

AddressXception
Copy link
Collaborator

Issue

Link your PR to an issue

Fixes #362

Description

Please describe your pull request.

Adds range proof for proving the contest selection limit. The constant proofs are left in the code for serialization compatibility for now but they are not used any more as part of the encryption or proof verification anymore.

Testing

Describe the best way to test or validate your PR.

  1. run the unit tests

adda generic zero knowledge struct that can hol the data for zk proofs. while it is only implemented in the range proof now, it should replace the disjunctive proof implementation to make the code more legible.
/// <summary>
/// Validation result for a zero knowledge proof
/// </summary>
struct ValidationResult {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

range proof returns a result with a collection of messages. this is currently only propagated in the cpp interface and not the c interface.

@@ -290,6 +290,62 @@ namespace electionguard
std::chrono::system_clock::time_point timePointFromIsoString(const string &time,
const string &format);

template <typename T>
std::vector<std::reference_wrapper<T>>
referenceWrap(const std::vector<std::unique_ptr<T>> &input)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there are a bunch of places in the code where this could be used (e.g. ballot selections and contests) but i stopped short of replacing those things for now to keep the scope narrow

Copy link
Collaborator

@john-s-morgan john-s-morgan left a comment

Choose a reason for hiding this comment

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

include/electionguard/chaum_pedersen.hpp Show resolved Hide resolved
src/electionguard/ballot.cpp Show resolved Hide resolved
src/electionguard/ballot.cpp Show resolved Hide resolved
src/electionguard/ballot.cpp Show resolved Hide resolved
src/electionguard/ballot.cpp Show resolved Hide resolved
src/electionguard/encrypt.cpp Show resolved Hide resolved
src/electionguard/encrypt.cpp Outdated Show resolved Hide resolved
src/electionguard/encrypt.cpp Show resolved Hide resolved
src/electionguard/encrypt.cpp Show resolved Hide resolved
src/electionguard/serialize.hpp Show resolved Hide resolved
@john-s-morgan
Copy link
Collaborator

@AddressXception please update branch target to milestone/nov-election. Main is currently being used for Appcenter builds.

Copy link
Collaborator

@john-s-morgan john-s-morgan left a comment

Choose a reason for hiding this comment

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

target branch needs to be updated.

@john-s-morgan john-s-morgan changed the base branch from main to milestone/nov-election July 17, 2023 15:14
@john-s-morgan john-s-morgan self-requested a review July 17, 2023 15:14
john-s-morgan and others added 17 commits August 1, 2023 13:15
* implement spec 2.0 hashes

* fix ballot compilation and validation issues

* add new constants from the E.G. 2.0 spec

* clang update

* fix hash nonce when decrypting on contest

fix prefix issues

---------

Co-authored-by: John Morgan <john.morgan@infernored.com>
Co-authored-by: John Morgan <70619927+john-s-morgan@users.noreply.github.com>
Copy link
Collaborator

@john-s-morgan john-s-morgan left a comment

Choose a reason for hiding this comment

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

lgtm

@john-s-morgan john-s-morgan merged commit 5ae0b09 into milestone/nov-election Aug 2, 2023
8 of 11 checks passed
@john-s-morgan john-s-morgan deleted the feature/range-proof branch August 2, 2023 00:08
john-s-morgan added a commit that referenced this pull request Aug 5, 2023
* Feature/consistent hashes (#370)

* try removing soversion of hacl_cpp lib and bifurcate the links for win

* add hash prefeixes

* add hash prefixes to hashes

rework some of the hashed elgamal interface to support hash prefix and encryption seed.

* fix encryption tests

* propagate hashed elgamal interface changes into c#

* pr self review

* add exports to new hash functions

* address PR feedback

---------

Co-authored-by: AddressXception <github@addressxception.com>

* Feature/base k elgamal (#371)

* pass publicKey into elgamal encrypt with precompute

* Implement Base-K ElGamal

swap the encryption base from generator G to public key K, per the EG 2.0 spec. Add encryptionBase to elgamal decrypt functions and invert the decryption algorithm per the spec. Modify the discrete log to accept any base for lookups.

* adjust realtime disjunctive cp proofs to new format

* rename precomputed values only use getters on precompute

* rename triple to PrecomputedEncryption

* rename Quadruple to PrecomputedFakeDisjuctiveCommitments

* rename TwoTriplesAndAQuad to PrecomputedSelection

* rename context get and pop functions

* break out cp proof tests

* Skip due to invalid Constant Chaum Pedersen proof

skip all of the tests that are failing which rely on the proof of selection limit being valid (which is pretty much every check that checks the ballot, including decryption

* refactor elgamal encrypt to support base-G

* refactor precompute overrides for disjunctive proof

* fix comments

---------

Co-authored-by: AddressXception <github@addressxception.com>

* Feature/logging (#385)

* Adding ILogger support and logging of the issues reported from the key and tally ceremonies

* Added a warming for a rejected ballot

* PR cleanups

* PR change

* Updated the version number

* Removed mutex from being used since the access is controlled from the… (#388)

* Removed mutex from being used since the access is controlled from the C# code and this caused a deadlock.

* changed delays since tests are failing on certain test runners

* removing the delay on the test for complete

---------

Co-authored-by: John Morgan <70619927+john-s-morgan@users.noreply.github.com>

* Feature/range proof (#366)

* Add range proof

adda generic zero knowledge struct that can hol the data for zk proofs. while it is only implemented in the range proof now, it should replace the disjunctive proof implementation to make the code more legible.

* replace constant proof with range proof

* remove placeholder selections from contest encryption

* Fix compile issue with chaum.  Cleaned up a export for HashPrefix

* pr review, try revert the hashprefix symbolication

* allow commitments to be optional

handle cases where commitments are null, such as when loading from an election record. re-enable constant proofs. fix missing const functions on elgamal keypair. add some documentation throughout. simplify unit tests.

* try re-enabling x86 builds in CI on windows

* comment out the pr branch rul so that we can test ci

* turn on intellisense for dotenv files

* C interface for ranged chaum pedersen proof

* disable auto serialization of contest proofc ommitments

* Update Hacl add support for msys2-x86

enable x86 builds using the msys toolchain and add them to the netstandard packaging process.

* export all symbols in msys & mingw

* try set symbols for win32

* try always export symbols

* reenable compilation check for export symbols

* Enhance logger to trap isValid messages

* Add cpp facade

* Add external C interface

* Add native interface for RangedChaumPedersen

* Add Ranged Chaum Pedersen

* Fixed the x86 build from compiling as x64

* Add unit tests

* There are no longer placeholders. Remove from validation

* try cmment out windows check for export headers

* add test to prove decrypt with secret works

* add a single shot test to capture decrypt with shares and filter for it

* minor cleanup

* fix elgamal decrypt.

use key ceremony data when available for GenerateFakeElectionData

* switching to clang for building the x86

* update makefile to match CI

* update flags to pacman

* fixed x86 build

* removed installing .net for the ci/cd

* using new update for the hacl defaults

* implement spec 2.0 hashes (#387)

* implement spec 2.0 hashes

* fix ballot compilation and validation issues

* add new constants from the E.G. 2.0 spec

* clang update

* fix hash nonce when decrypting on contest

fix prefix issues

---------

Co-authored-by: John Morgan <john.morgan@infernored.com>
Co-authored-by: John Morgan <70619927+john-s-morgan@users.noreply.github.com>

* removed copy_n

* update R test

* remove R test

* CLI does not need to depend on nuget package

* Button layout update for tally

* export record if file exists

* Change verify to green mark

* Update targets for x86

* fix folder structure in pipeline

---------

Co-authored-by: SteveMaier-IRT <steve.maier@infernored.com>
Co-authored-by: John Morgan <john.morgan@infernored.com>
Co-authored-by: John Morgan <70619927+john-s-morgan@users.noreply.github.com>

* update shell for x86

* library fix

* switch build to msvc for x86

* setting 32 bit processor to run on 32bit shell

* Task/UI cleanup (#393)

* isolate windows-specific code

* update version in UI

* try using build toolchain for tests

* try force a recompile

* reset use precompute to true for nov election

* use explicit flags for executing tests

remove the test toolchains in favor of the os/processor toolchains which support cross-compilation

* add a test for validating precompute

this test is as close as possible to validating that precompute is working by default in the c# layer.

* adjust x86 release pipeline path files

* replace the test data

* overload is valid check in web assembly

* drive ready (#395)

* lowercase files (#403)

* Enhance logging for decryption. (#405)

merge pending a review by @SteveMaier-IRT

* Changes due to integration testing with election product (#406)

Changes due to intergration testing

* QA updates from integration test with CP Vendor (#410)

* allow for all file types

* encrypt to an encrypted_ballots folder

* use ballotcode instead of Tally ID

* Handle no ballots in folder

* Only create elections when at least one key ceremony is complete

* support no file extension means removing filter altogether

* update filter

* remove space

* logging for Tally

* update viewmodels

* Logout on db error.

* Create election db handling

* reenable branch PR CI rule

* try include x86 in nuget

* Fix unit tests for netstandard

---------

Co-authored-by: John Morgan <70619927+john-s-morgan@users.noreply.github.com>
Co-authored-by: Steve Maier <82616727+SteveMaier-IRT@users.noreply.github.com>
Co-authored-by: SteveMaier-IRT <steve.maier@infernored.com>
Co-authored-by: John Morgan <john.morgan@infernored.com>
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.

✨ Add Range proofs
3 participants