A C++ implementation of ElectionGuard specification focused on encryption components.
Перейти к файлу
Steve Maier 370fdff223
For null string values for candidate and party, set them to an empty string (#313)
Created C# unit test
2022-06-23 09:57:08 -04:00
.github Updating release workflow with VS2022 (#303) 2022-06-09 12:35:26 -04:00
.vscode Device issue (#290) 2022-06-07 02:31:45 -04:00
bindings For null string values for candidate and party, set them to an empty string (#313) 2022-06-23 09:57:08 -04:00
cmake Encrypt CompactPlaintextBallot (#162) 2021-03-29 15:18:07 -04:00
data Feature/netframework api (#175) 2021-05-20 09:43:09 -04:00
docs Feature/election c api (#146) 2021-02-05 12:10:41 -08:00
include Fix/default fix (#301) 2022-06-09 11:46:51 -04:00
src Setup default value for votes_allowed to match the number_elected (#312) 2022-06-21 18:59:33 -04:00
test - Add checks for the context and manifest matching manifesthash values (#306) 2022-06-15 10:11:47 -04:00
.clang-format Initial .net framework examples (#172) 2021-04-30 09:52:42 -04:00
.clang-tidy Feature/test elgamal (#55) 2020-09-24 12:58:54 -04:00
.gitattributes.txt Whitespacing fix (#258) 2022-04-20 09:31:47 -04:00
.gitignore CPP CLI (#295) and VS2022 (#247) 2022-06-07 17:24:38 -04:00
CMakeLists.txt Fixed new constructor for the Manifest (#282) 2022-05-20 11:03:32 -04:00
CMakeSettings.json Feature/msvc (#166) 2021-04-16 13:53:46 -04:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2020-05-05 06:41:56 -07:00
CONTRIBUTING.md Adjust Contributing and Add templates 2021-09-20 15:19:46 -04:00
LICENSE Initial LICENSE commit 2020-05-05 06:41:59 -07:00
Makefile CPP CLI (#295) and VS2022 (#247) 2022-06-07 17:24:38 -04:00
README.md 📝 Added Repo Relative Link (#220) 2021-10-21 15:21:34 -04:00
SECURITY.md Initial SECURITY.md commit 2020-05-05 06:42:00 -07:00

README.md

Microsoft Defending Democracy Program: ElectionGuard Python

🗳 ElectionGuard C++

ElectionGuard Specification 0.95.0 Github Package Action license license

This repository is a "reference implementation" of an ElectionGuard ballot encryption library written in c++ and includes a C-compatible API for referencing the library from pure-c application. This core SDK performs ballot encryption and verification functions and is suitable for execution on voting system hardware and low powered devices. It is designed to be integrated into existing (or new) voting system software.

This repository is pre-release software to showcase the ElectionGuard API implemented in a native language. It is not feature complete and should not be used for production applications.

📁 In This Repository

File/folder Description
.github Github workflows and issue templates
.vscode VS Code configurations
/bindings Binding interfaces for different languages
/cmake CMake dependencies`
/include Public include headers
/src ElectionGuard source code
/test Unit tests
.clang-format Style guidelines
.gitignore Define what to ignore at commit time.
CMakeLists.txt Root CMake file
CONTRIBUTING.md Guidelines for contributing to the sample.
README.md This README file.
LICENSE The license for the sample.

What Is ElectionGuard?

ElectionGuard is an open source software development kit (SDK) that makes voting more secure, transparent and accessible. The ElectionGuard SDK leverages homomorphic encryption to ensure that votes recorded by electronic systems of any type remain encrypted, secure, and secret. Meanwhile, ElectionGuard also allows verifiable and accurate tallying of ballots by any 3rd party organization without compromising secrecy or security.

Learn More in the ElectionGuard Repository

🦸 How Can I use ElectionGuard?

ElectionGuard supports a variety of use cases. The Primary use case is to generate verifiable end-to-end (E2E) encrypted elections. The ElectionGuard process can also be used for other use cases such as privacy enhanced risk-limiting audits (RLAs). This implementation only includes encryption functions and cannot be used to generate election keys and it cannot decrypt tally results.

This c++ implementation also includes a C API that can be consumed from anywhere that can call C code directly. A .Net Standard package is also provided.

💻 Requirements

All Platforms

  • A C++17 standard compliant compiler is required to build the core library. While any modern compiler should work, the library is tested on a subset. Check out the GitHub actions to see what is officially supported.
  • GNU Make is used to simplify the commands and GitHub Actions. This approach is recommended to simplify the command line experience. This is built in for MacOS and Linux. For Windows, setup is simpler with Chocolatey and installing the provided make package. The other Windows option is manually installing make.
  • CMake is used to simplify the build experience.

🤖 Android

To build for android, you need the Android SDK and platforms 21 and 26. The easiest way is to download android studio. Alternatively, you can use the SDK installation that ships with the Xamarin Tooling in Visual Studio. WE also require the use of the Android NDK. Android builds can be compiled on Linux, Mac, or Windows

🍏 iOS

To build for iOS you need XCode installed

Linux

The automated install of dependencies is currently only supported on debian-based systems. See the makefile for more information.

🖥️ Windows (using MSVC)

Building on windows is supported using the MSVC toolchain.

  • Install Chocolatey
  • Install Powershell Core
  • Install VS 2019
  • Open the Visual Studio Installer and install -- MSVC v142 - VS 2019 C++ x64/x86 build tools -- Windows 10 SDK (latest) -- C++ CMake tools for Windows -- C++/CLI support for v142 build tools

🖥️ Windows (using MSYS2)

Building on windows is supported using the MSYS2 toolchain. MSYS is the default toolchain on Windows.

  • Install Chocolatey
  • Install Powershell Core
  • Install MSYS2
  • Open the MSYS2 prompt by running the newly-created "MSYS2 MSYS" shortcut in your start menu.
  • Inside the prompt, run pacman -Syu, then close the window when it prompts you to.
  • Reopen the MSYS2 prompt and run:
    pacman -Syu
    pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake make
    
  • Modify your %Path% to include the newly-installed software. You should include these two paths:
    C:\msys64\mingw64\bin
    C:\msys64\usr\bin
    

🚧 The Procedure Entry Point Could not be Located

When compiling with shared libraries, you may encounter an error running the unit tests project. This is likely due to windows resolving the incorrect implementation of libstdc++-6.dll. Solving this depends on your use case, but you can either ensure that the path modifications made above appear before any other paths which include this library (e.g. c\Windows\System32), or you can include a copy of the correct DLL in the output folder. See this StackOverflow post for more information

🌐 .NET Standard

A .NET Standard binding library is provided so that this package can be consumed from C# applications. At this time, MacOS, Linux and Windows are supported.

Build C++

Using make,

Download Dependencies

make environment

Build the Library for the current host (Release, default toolchain)

make build

Build the Library for the current host (Debug, default toolchain)

export TARGET=Debug && make build

Android

The Android Build currently Targets API Level 26 but can be configured by modifying the Makefile

Set the path to the NDK, replacing the version with your own

export NDK_PATH=/Users/$USER/Library/Android/sdk/ndk/21.3.6528147 && make build-android

iOS

The iOS build currently targets iPhone OS 12 but can be configured by modifying the Makefile

Creates a fat binary for the simulator and targets a recent version of iOS

make build-ios

Windows

Using the default MSYS2 toolchain:

make build

Using the MSVC toolchain:

make build-msvc

Build Wrappers

.Net Standard 2.0

Wraps the build artifacts in a C# wrapper conforming to .Net Standard 2.0.

make build-netstandard

.Net Framework v4.8

Wraps the MSVC build artifacts in a C++/CLI wrapper to be consumed from a .Net Framework 4.8 application (windows desktop only). Only works on Windows.

// ensure the windows msvc binaries are built
make build-msvc

open ./bindings/netframework//ElectionGuard.NetFramework/ElectionGuard.NetFramework.XXX.sln in VS 2019 and build.

Running the .Net Framework Benchmark

Open the NetFramework solution and run the ElectionGuard.Bench project

Test

Running the C++ and C tests

make test

Running the tests on Windows using the MSVC toolchain

make test-msvc

Running the netstandard tests

To run the tests when building for the current host (Linux, Mac, windows:)

make build-netstandard
make test-netstandard

To run the tests when building for a mobile device, you can run the .Net Standard tests using the Xamarin Test runner on the Android Emulator or the iOS simulator:

NOTE: Xamarin build support is temporarily disabled while the project migrates to the new SDK style project format. Please refer to ISSUE #195 for more information.

make build-netstandard

Then, open Visual studio for Mac and run the ElectionGuard.Tests.Android or ElectionGuard.Tests.iOS project.

📄 Documentation

Contributing

This project encourages community contributions for development, testing, documentation, code review, and performance analysis, etc. For more information on how to contribute, see the contribution guidelines

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Reporting Issues

Please report any bugs, feature requests, or enhancements using the GitHub Issue Tracker. Please do not report any security vulnerabilities using the Issue Tracker. Instead, please report them to the Microsoft Security Response Center (MSRC) at https://msrc.microsoft.com/create-report. See the Security Documentation for more information.

Have Questions?

ElectionGuard would love for you to ask questions out in the open using GitHub Discussions. If you really want to email the ElectionGuard team, reach out at electionguard@microsoft.com.

License

This repository is licensed under the MIT License

Thanks! 🎉

A huge thank you to those who helped to contribute to this project so far, including:

Josh Benaloh (Microsoft)

Keith Fung (InfernoRed Technology)

Matt Wilhelm (InfernoRed Technology)

Dan S. Wallach (Rice University)

Marina Polubelova (INRIA Paris)

Santiago Zanella-Béguelin (Microsoft Research)

Jonathan Protzenko (Microsoft Research)