Independent Python verifier for ElectionGuard election results.
Project description
ElectionGuard Verify
An ElectionGuard Verifier, in Python
This repository contains an independent verifier for elections conducted using Microsoft's ElectionGuard system.
:exclamation: | The official ElectionGuard Python implementation contains inconsistencies with the ElectionGuard cryptographic specification. Until these are resolved, the ElectionGuard Python implementation should be considered insecure. |
---|
Overview
ElectionGuard Verify is a Python package and corresponding command line utility which cryptographically verifies the results of election's conducted using Microsoft's ElectionGuard system. This package takes as input the artifacts published as the results of an ElectionGuard election.
This code can be consumed as a Python package used within other applications or as a standalone command line utility.
Installation
ElectionGuard Verify can be installed via pip
:
pip install electionguard-verify
Alternatively, it can be installed from source:
git clone https://github.com/nickboucher/electionguard-verify.git
pip install ./electionguard-verify
The installation requires Python 3.8+. This requirement is, unfortunately, set by the official electionguard
Microsoft package which is consumed for useful data structure definitions.
The installation depends on the gmpy2
Python package, which is a high-performance library for general multi-precision arithmetic commonly used in cryptographic applications. Many OSs do not ship with the binaries required for this package to work. For example, if you experience installation issues with this dependency on MacOS, you can use the brew
package manager to install the missing system dependencies via brew install libmpc mpfr
. For other platforms, you can find various tutorials on installing this package's dependencies through your search engine of choice.
Usage
ElectionGuard Verify can be consumed as either a command line utility or a standard Python package.
Command Line Utility
The command line utility egverify
is automatically installed and added to the PATH of your current Python environment during installation. This command line utility is the easiest way to use this verifier, as no additional code is required.
To begin verification of an election, simply run the following command:
egverify RESULTS_DIR
where RESULTS_DIR
is the directory containing the artifacts published as the result of any ElectionGuard election. If no value is provided, the tool will run against the current working directory.
There are a variety of other options that can be specified, although most won't be necessary for standard elections. The key options are:
-v
,--verbose
: This flag configures the verifier to output information about the verification steps while running.-n
,--no-warn
: This flag will silence all warnings that the verifier outputs. You probably don't want to specify this flag.
Additional options exist to override the default naming conventions of the files in RESULTS_DIR
. It is very unlikely that these options will need to be specified. To view a full list of options, run egverify --help
.
Python
ElectionGuard Verify can also be consumed as a standard Python package, thus allowing ElectionGuard elections to be verified programmatically as part of a larger software pipeline.
There is a single function called verify
which will perform all steps required to cryptographically verify an ElectionGuard election. It can be imported as:
from electionguard_verify import verify
In order to invoke this function, though, you will need to supply it with a deserialized version of the election results. You will likely want to use the official Microsoft electionguard
package to import the correct data structures and deserialization functions. An example of this can be found in electionguard_verify/command_line.py
.
The typed function signature of verify
is:
def verify(
description: ElectionDescription,
context: CiphertextElectionContext,
constants: ElectionConstants,
devices: Iterable[EncryptionDevice],
ciphertext_ballots: Iterable[CiphertextAcceptedBallot],
spoiled_ballots: Iterable[CiphertextAcceptedBallot],
ciphertext_tally: PublishedCiphertextTally,
plaintext_tally: PlaintextTally,
coefficient_validation_sets: Iterable[CoefficientValidationSet] = None
) -> bool
The function returns True
for a valid election and False
for an invalid election. Logging verbosity level can be set using the Python standard library logging
package.
Feedback
The author of this package invites anyone to review the code for implementation errors. Such a pursuit is likely performed most fruitfully in consultation with the ElectionGuard formal specification, which can be downloaded as human-readable document from the releases section of the primary Microsoft ElectionGuard repository. Knowledge of modular arithmetic and zero-knowledge proofs will also be helpful. Please open issues on GitHub for any discovered bugs.
Disclaimers
This codebase was developed independently of Microsoft. The original author, however, has a Microsoft affiliation as a full-time employee in a non-ElectionGuard organization within Microsoft.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file electionguard_verify-0.1.tar.gz
.
File metadata
- Download URL: electionguard_verify-0.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2e5ce9fe3e1b35f94dc95e31ba2e896d73670e889b0e88ac8210a502eaacd4 |
|
MD5 | 03c820356802e7d2478f502bb5ba7605 |
|
BLAKE2b-256 | f36dbdba2f4264da341792b8cc2a68981d1a863fb832f79b57528ea7d9307c8d |
File details
Details for the file electionguard_verify-0.1-py3-none-any.whl
.
File metadata
- Download URL: electionguard_verify-0.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eee67c2bce9b82169abcee08fcb9da5d8004419e5eac86157bb6c19a49d13ca0 |
|
MD5 | 692878269b698c966f5f0d8bc87d5f47 |
|
BLAKE2b-256 | 35b4fe78647b14e910511b83da736ca066e047f0a30e878d497c0bb93342188a |