The election process to elect future representatives for the government still has major flaws. The process takes too long, and election results cannot be verified by the individual, mathematically. The following app should help with this.
- each citizen is authenticated by the government
- election results can be verified by each individual
- votes should be bundled before data is written to the blockchain
- ecards should allow storing blockchain identities (technological hurdle)
The following code runs on top of the official id card app, AusweisApp2. AusweisApp2 needs to be installed on the system running the code. It allows connecting to the app using the WebSocket protocol. 1
var WebSocketClient = require('websocket').client;
var needle = require('needle');
var client = new WebSocketClient();
let cardPIN="<PIN>"
client.on('connectFailed', function (error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function (connection) {
console.log('WebSocket Client Connected');
connection.on('error', function (error) {
console.log("Connection Error: " + error.toString());
});
connection.on('close', function () {
console.log('echo-protocol Connection Closed');
});
connection.on('message', function (message) {
if (message.type === 'utf8') {
console.log("Received: '" + message.utf8Data + "'");
// respond
try {
let parsedData = JSON.parse(message.utf8Data);
if (parsedData.msg == 'AUTH') {
// console.log('auth message received')
JSON.stringify(parsedData)
}
if (parsedData.msg == 'ACCESS_RIGHTS') {
// console.log('ACCESS RIGHTS message received')
JSON.stringify(parsedData)
// accept current state, access rights
let commandAcceptState = JSON.stringify({ cmd: "ACCEPT" })
connection.sendUTF(commandAcceptState);
}
if (parsedData.msg == 'ENTER_PIN') {
// console.log('ENTER PIN message received')
JSON.stringify(parsedData)
// send PIN to unlock card
let commandSendPIN = JSON.stringify({ cmd: "SET_PIN", value: cardPIN })
console.log('Sending SET_PIN and payload')
connection.sendUTF(commandSendPIN);
}
if (parsedData.msg == 'AUTH' && parsedData.result.major == 'http://www.bsi.bund.de/ecard/api/1.1/resultmajor#ok') {
let responseData = parsedData.url
console.log(`response data ${responseData}`)
needle('get', responseData)
.then(function (resp) {
let data = resp.body;
console.log(data)
console.log(`personal data ${JSON.stringify(data.PersonalData)}`)
})
.catch(function (err) {
console.log(`error getting response ${err}`)
});
}
}
catch (e) {
console.log(`error ${e}`);
}
}
});
if (connection.connected) {
// let command = JSON.stringify({ cmd: "GET_INFO" })
// run authentication
// url reference https://github.com/buergerservice-org/workflowLibrary/blob/master/workflowLibrary.cpp
let tcTokenURL = `https://www.autentapp.de/AusweisAuskunft/WebServiceRequesterServlet?mode=json`;
let commandAuthenticate = JSON.stringify({ cmd: "RUN_AUTH", tcTokenURL: tcTokenURL })
connection.sendUTF(commandAuthenticate);
}
});
client.connect('ws://localhost:24727/eID-Kernel');
- For Waves Blockchain, this library can be used to generate new wallets @waves/provider-seed - npm (npmjs.com)
- once the wallet has been created the public key will be stored alongside the ecard identity
- the government creates a wallet for its own - the wallet will allow to encrypt all voting data before it is written to the blockchain 2
- create a blockchain application (distributed app - dApp) 3, use script example to create a voting application 4
- once the app has been created, voting is facilitated calling the script function "vote" from the frontend app
- create the frontend app cloning the repository and adjusting the code to match the needs, address of account related to the dapp, function name, and voting data, to sent from the frontend app 5