Giter Site home page Giter Site logo

anarvote / helios_lib Goto Github PK

View Code? Open in Web Editor NEW
12.0 5.0 5.0 70 KB

Helios Server (Helios is an end-to-end verifiable voting system) as library

License: MIT License

Python 100.00%
helios evoting evote verifiable voting voting-application voting-system elgamal elgamal-encryption zero-knowledge

helios_lib's Introduction

The Helios Lib

Build Status

This is Helios-Server (Helios is an end-to-end verifiable voting system.) as library,

This helios_lib version is completely independent of Django.

Install

>>> pip install helios_lib

Test

>>> pytest --fulltrace -s helios_lib/

Example

from helios_lib.models import HeliosElection, HeliosVoter
from helios_lib.config import ELGAMAL_PARAMS

# Create election
helios_election = HeliosElection()

# Add trustee
trustee_default = helios_election.generate_helios_trustee(ELGAMAL_PARAMS)
helios_election.trustees.append(trustee_default)

# Add questions
question = HeliosElection.create_question(answers_count=5, minimum=0, maximum=2, result_type='relative')
helios_election.questions = [question]

# Add voters
voters_count = 4
helios_election.voters = [HeliosVoter() for _ in range(voters_count)]

# Freeze the election
helios_election.freeze()

# Cast votes, Encrypt votes of voters on the helios_lib side
helios_election.voters[0].vote = helios_election.encrypt_ballot('[[0,4]]')
helios_election.voters[1].vote = helios_election.encrypt_ballot('[[0]]')
helios_election.voters[2].vote = helios_election.encrypt_ballot('[[1]]')
helios_election.voters[3].vote = helios_election.encrypt_ballot('[[1,4]]')

# Verify votes of voters
for v in helios_election.voters:
    v.vote.verify(helios_election)

# Tally election
helios_election.num_cast_votes = 4
helios_election.compute_tally(helios_election.voters)
helios_trustee = helios_election.get_helios_trustee()
helios_election.helios_trustee_decrypt(helios_trustee)
helios_election.combine_decryptions()

# Result of election
assert helios_election.result == [[2, 2, 0, 0, 2]]

For more complex example refer to tests

helios_lib's People

Contributors

omidraha avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

helios_lib's Issues

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.