Giter VIP home page Giter VIP logo

electionguard-core2's Introduction

Microsoft Defending Democracy Program: ElectionGuard Core2

πŸ—³ ElectionGuard Core2

ElectionGuard Specification 1.1.0 Github Package Action license license

This monorepo contains the ElectionGuard 2.0+ code. The core functionality is implemented in C++ for performance and interoperability. It provides functionality for all ElectionGuard workflows including key ceremony, ballot encryption, tally, ballot decryption, and verification. It is designed to be integrated into existing (or new) voting system software. It includes a variety of interop layers to provide functionality to languages including C, .NET, and Java.

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.

Web Assembly

Building for WebAssembly (wasm) is supported with the emscripten toolchain. This currently is setup for compiling on Linux and Mac only.

  • Install emscripten
  • Install Node Version Manager
  • Ensure the latest versions of both emscripten and node are activated
  • Ensure Emscripten and node are both in your path
  • run make test-wasm to build for wasm and validate the library.

πŸ–₯️ Windows (using MSVC)

Building on windows is supported using the MSVC toolchain. MSVC is the default toolchain on Windows. All of these tools should be installed as admin or in a command prompt as admin to make sure that all of the security settings are appropriate. As for the Visual Studio 2022 install, VS 2022 Community edition will work for developing ElectionGuard. You also may use Professional or Enterprise versions.

🚧 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 MSVC 2022 toolchain (with optional platform builds):

make build
make build-arm64
make build-x86
make build-x64

Build Wrappers

.Net Standard 2.0

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

make build-netstandard

Test

Running the C++ and C tests on Windows using the MSVC toolchain

make test

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.

Command Line Interface

There is a command line interface in the ./apps/electionguard-cli folder. This is a tool useful for generating test data and interacting with ElectionGuard.

make build-cli
make test-cli
make verify

πŸ“„ 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 [email protected] 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.

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)

Michael Naehrig (Microsoft)

Olivier Pereira (Microsoft)

RC Carter (Election Tech)

Steve Maier (InfernoRed Technology)

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)

electionguard-core2's People

Contributors

addressxception avatar avinal avatar awaistanveer avatar dependabot[bot] avatar dryercashew avatar edsnider avatar jayita10 avatar jeffspel-crypto avatar jessewdouglas avatar john-s-morgan avatar keithrfung avatar lprichar avatar matthewratzell avatar microsoftopensource avatar msprotz avatar pamtaro avatar pradumnasaraf avatar rc-ms avatar stevemaier-irt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electionguard-core2's Issues

✨ Reduce compiler warnings in C++

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

No response

Possible Implementation

No response

Anything else?

No response

✨ Code signing cert for UI

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Need a code signing certificate for UI app

Possible Implementation

No response

Anything else?

No response

✨ Unit tests for Localization

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add unit tests for localization resource manager. Likely this will include extracting to the library project

Possible Implementation

No response

Anything else?

No response

create a docker env for c++

build errors on Mac continue to be an issue
good enough is John is able to build in this env
nice to have if time permits - c# as well

✨ Naming: KeyCeremonyMediator

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

As a developer, I want to understand when we are using a mediator architecture pattern versus an object that has mediator in the name.

Look into better options for naming.

Possible Implementation

No response

Anything else?

No response

✨ Fix Perf on GCC CI Build

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Replace the C++ unit test asserts with something that will work in release mode, and then switch the GCC build to release mode. Verify that asserts are working before PR.

Possible Implementation

No response

Anything else?

No response

✨ Real time communication

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Enable real time communication between Admin and guardian(s)

Possible Implementation

No response

Anything else?

No response

✨ CI build for UI

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Build UI in the CI on PR request.

Possible Implementation

No response

Anything else?

No response

🐞 make environment fails to create symlink for 🍎os

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

make environment fails on ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy". the output of the command does not seem to be appending to set the appropriate symlink.

ln -s "/bin/clang-tidy" "/usr/local/bin/clang-tidy" is the resultant command, which is not correct.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

✨ Settings Page

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add a settings page to handle the settings for database ip and password and future UI settings.

Possible Implementation

No response

Anything else?

No response

🐞 Unicode gets double escaped when serializing to json

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

.ToJson() converts ΓΊ to \u00f

Expected Behavior

.ToJson() converts ΓΊ to \u00f

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

✨ Clean Up Benchmark

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

In bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Bench/BenchEncrypt.cs extract device.GetHash() to intermediate variables.

Possible Implementation

No response

Anything else?

No response

✨ Key Ceremony > Create key

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

No response

Possible Implementation

No response

Anything else?

No response

✨ Add UI for Administrators

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

No response

Possible Implementation

No response

Anything else?

No response

✨ Fix all build warnings

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

The C++ build process has many warnings, some of these could be very important to make sure to look at, but since they are only warnings, they do not stop the build and people may overlook them. The code needs to have all of the warnings fixed.

Possible Implementation

No response

Anything else?

No response

✨ Add Localization Support to the UI

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

For the new MAUI app, localization support should be added to allow for at least Spanish to be added to the system and other languages later if needed.

Possible Implementation

No response

Anything else?

No response

🐞 UI won't run due to missing guard

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

No response

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

🐞 Contest and Selection Can Leak Memory

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If you create a PlaintextBallotSelection or PlaintextBallotContest in C# and immediately dispose of them, the underlying C++ won't get disposed and you'll have a memory leak. The underlying C++ objects currently only get disposed when you add them to a ballot and then dispose of the ballot.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

✨ Connect to datastore

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Setup database connection. Settings exposed to user. Check if this is first time setup and request info

Possible Implementation

No response

Anything else?

No response

✨ Election Detail Page

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add a page to allow the user to view the details for an election and perform work on the election.

This should use the Python UI as a beginning point.

image

Possible Implementation

No response

Anything else?

No response

✨ Add basic UI page structure

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add a basic login, admin home page, and guardian home page and allow the navigation back and forth.

Possible Implementation

No response

Anything else?

No response

✨ Code Generation for Methods

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Code generation for methods doesn't currently support parameters that are out params in C++ and return's in C#.

Possible Implementation

No response

Anything else?

No response

✨ Extract sanitizer out of PR CI

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Extract sanitizer

Possible Implementation

No response

Anything else?

No response

✨ Remove 32-bit

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

For EG 2.0 there is no need to continue with the 32-bit compiling, test, and other usage. This should be removed from the project.

Possible Implementation

No response

Anything else?

No response

✨ Consistent logging

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Research and create proper log handling in c++, c and c# for consistency.

Moved from cpp project

Possible Implementation

No response

Anything else?

No response

🐞 Fix Sanitizer Workflow

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The sanitizer workflow needs to be changed from using ubuntu-latest to ubuntu-22.04 since the latest flag might not apply to our build server until Dec 1.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

✨ Key Ceremony - expose methods to C interop interface

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Expose existing C++ functions to C interface:

  • rand_q

implement in C++ the equivalent math functions and provide to C# interop:

  • add_q
  • make_schnorr_proof

Possible Implementation

No response

Anything else?

No response

✨ Numeric validation of an Entry

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

As a developer, I want to validate a numeric field as an integer

Possible Implementation

No response

Anything else?

No response

Create Election Page

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add a page to create a new election. This could also include the key ceremony selection / creation.

Possible Implementation

No response

Anything else?

No response

✨ Reduce compiler warnings in C#

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

No response

Possible Implementation

No response

Anything else?

No response

🐞 text box on mac ui black with white text

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

fix textboxes (e.g. login) for macCatalyst

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:

Anything else?

No response

✨ Review Test_Multiple_Submit()

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Look into bindings/netstandard/ElectionGuard/ElectionGuard.Encryption.Tests/TestEncrypt.cs's Test_Multiple_Submit() method. Specifically to understand the goal of what we are testing.

Also refactor for loop to use something more modern

Possible Implementation

for loop option:

Enumerable.Range(1,10000).ForEach(using new SubmittedBallot(ciphertext, BallotBoxState.Cast));

Anything else?

No response

Key Ceremony > Share Key

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

No response

Possible Implementation

No response

Anything else?

No response

✨ Add Yubikey support for user login

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Ability to use a Yubikey to allow the user to log into the UI software.

Possible Implementation

No response

Anything else?

No response

✨ Unit tests for viewModels

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

As a developer, I need my view models to be unit testable

Possible Implementation

No response

Anything else?

No response

✨ Remove .NET Framework project

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Remove the old .NET Framework project, code, and build process.

Possible Implementation

No response

Anything else?

No response

Consistent logging

Research and create proper log handling in c++, c and c# for consistency.

✨ Code Generation of C# and C Headers

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Add code generation to we can more easily support Java and TypeScript interfaces in addition to C# as we make changes going forward.

Possible Implementation

No response

Anything else?

No response

✨ Update Github Action Settings

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

The OS and language version settings need to be updated to the latest ones.
The android NDK_PATH should also be updated to one that is available in the builds.

Possible Implementation

No response

Anything else?

No response

✨ Add linting to UI

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

Jetbrains CLI linter tool does not currently support net7.0. Update when support has been added by the vendort

Possible Implementation

No response

Anything else?

No response

✨ Expose decrypt function

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

in C++ and C# packages, support and expose a decrypt function.

Possible Implementation

No response

Anything else?

No response

✨ ignore .vscode logs from build

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

ignore vscode build logs

Possible Implementation

No response

Anything else?

No response

✨ Add a database

Is there an existing issue for this?

  • I have searched the existing issues

Suggestion

We need a database that can read and write json

Possible Implementation

No response

Anything else?

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.