python-dirbtuves / internet-voting Goto Github PK
View Code? Open in Web Editor NEWInternet voting system.
Internet voting system.
For this, I think you can use aiohttp it seems to fit our needs as a mix-net node very well.
For this task just create simplest possible server implementation, that outputs It works!
on each request to /
.
For crypto part use https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/
Here is how this function could look:
envelope = create_envelope(nodes, content)
nodes
should be list of tuples tuple has two elements: node's IP address and public key.
content
should be any JSON serializable object.
Returned envelope
can be deserialized with primary keys of nodes in reverse order.
As a voter I would like to be able to prove my identity by using OAuth (and Valdžios vartai in future) service.
As an observer I would like to be able to publish my public key in order to be able to participate in mixnet (all participants should be reliable in mixnet).
Technical details:
use python-cryto module (not shell sshkey-gen).
As VRK representative I would like to be able to publish public key
Generate primary and public keys and return serialized values of these keys.
For this we need a wrapper functions with following API:
serialized_private_key, serialized_public_key = generate(password)
primary_key = load_private_key(serialized_private_key, password)
public_key = load_public_key(serialized_public_key)
serialization.Encoding.DER
serialization encoding should be used. And for the encoding use serialization.PrivateFormat.PKCS8
for private key and serialization.PublicFormat.SubjectPublicKeyInfo
for public key.
See: https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/
Use this:
encoding = serialization.Encoding.DER
format = serialization.PublicFormat.SubjectPublicKeyInfo
public_key_bytes = public_key.public_bytes(encoding, format)
fingerprint = hashlib.sha1(public_key_bytes).hexdigest()
First, you need to create setup.py file for internet voting library. This repository will be used for library purposes, together with basic command line client. So thing about this repository more like a library rather than command line client.
For command line script use console scripts entry point.
Use Python 3.
For command line script arguments use argparse.
Basically what you need to do is this:
$ voter <id> <subcommand>[ <arguments>]
For example:
$ voter 1 register
{'id': '1', 'command': 'register', 'args': []}
$ voter 1 verify voters
{'id': '1', 'command': 'verify voters', 'args': []}
$ voter 1 vote
{'id': '1', 'command': 'vote', 'args': []}
$ voter 1 verify my vote
{'id': '1', 'command': 'verify my vote', 'args': []}
$ voter 1 verify all votes
{'id': '1', 'command': 'verify all votes', 'args': []}
$ voter 1 count votes
{'id': '1', 'command': 'count votes', 'args': []}
As you see, subcommand can have more than one word, also there should be fixed list of known commands if an unknown command will be entered, show error message.
I would suggest to pop arguments and take voter id and subcommand and then pass arguments of subcommand to be process using argparse.
As a voter I would like to be able to publish my public key, which I generated by myself.
There are several places, where CEC has to sign something. For this, we need a function that can incrementally sign data stream.
Function signature could look something like this:
for hash, signature in sign(data, state):
pass
Here hash
is SHA-1 hash, signature
is a hash of hash
signature made with CEC private key. hash
and signature
both have to be incremental, meaning that if you will hash all data
you will get hash
from the last sign
call with last passed data
.
data
is an iterable of strings.
state
is an optional argument and if state
is given, then it should continue hashing from where it left. I'm not sure how to implement this, if will have to find-out it yourself. But the idea, that it should be enough to hash only new items, not everything from the beginning.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.