cryptographically-verifiable-elections-using-immudb


Cryptographically verifiable elections using immudb and Golang

Valentin, one of our engineers started a nice side project to show the possibilities of immudb. His goal is to showcase a website that provides a secure way for elections.

Powered by immudb

The main feature is that the voting platform built on immudb is automatically verified by everyone who visits the website! So immudb could run on an untrusted system, but the amount of users visiting the website makes it impossible to manipulate the data unnoticed.

  • Electronic voting system allowing anyone to act as an auditor and (cryptographically) verify that the election data has not been tampered.
  • The cryptographic verification, a.k.a the consistency proof, is achieved by leveraging the core features of immudb. It is based on multiple Merkle Trees.

If you just want to go ahead and visit the GitHub project: https://github.com/padurean/immuvoting

Continue reading to get some more information about how it works.

The verification Go code

The code gets compiled to WASM and resides in the VerifyConsistency function.

In it’s definition the code is split in 5 steps (there are comments in the code, marking each step):

  1. Get the local state which was persisted to local storage during a previous run
  2. Get the current server (immudb) state by sending a GET /state request to the immuvoting REST server. NOTE: when interracting with immudb directly, through an SDK, the CurrentState method must be used instead
  3. Get a verifiable transaction between the local and current states by sending a GET /verifiable-tx to the immuvoting REST server. NOTE:when interracting with immudb directly, through an SDK, the VerifiableTXByID method must be used instead
  4. Use the verifiable transaction to do the actual verification. This will run only in the client browser, with no other interraction with the server. Show the result of the verification in the UI; OK or Tampered
  5. If the verification passed, persist the fresh state from the server (obtained at step 2.) to local storage (overwrite the previous one), otherwise do nothing (keep the last non-tampered state in local storage)

To compile the verification code to WebAssembly

  1. Compile as WASM, outputing to the client folder:
    GOOS=js GOARCH=wasm go build -o ../client/verifier.wasm ./verifier/verifier.go*
  2. Make sure wasm_exec.js is present in the client folder. If it’s not there, copy it from your Go distribution:
    cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./client/

Short demo video


How to run it

Prerequisites

  • immudb v0.9.x – the immutable database. GitHub repo is here. More details about it can be found on it’s official site.

  • A modern browser (the web interface uses relatively new HTML and ES6 features – e.g. the featch API, const keyword etc.).

Fire it up!

  • Run immudb

NOTE: immuvoting will try to connect to it using default config: localhost, port 3322, database defaultdb and default credentials (have a look in server/main.go for more details)

  • from immuvoting‘s server folder run:

    • go get ./...
    • go run . to start the HTTP API server (backend)
  • a separate HTTP server needs to be started to serve the frontend (in the client folder) – e.g. if using VSCode, you can just use it’s Go Live feature; or you can use any other solution, like python -m SimpleHTTPServer.

That’s all. You can now access the fronted at http://localhost:<xxx&gt;.

NOTE: Port number depends on the HTTP server you used: default port for VSCode‘s Go Live it’s 5500, for python’s SimpleHTTPServer it’s 8000.


Miscellanea

  • The cryptographic verification of the election data (a.k.a. the consistency proof or tampering proof) is written in Go and it’s code resides in server/verifier/verifier.go.
    It is compiled to WebAssembly (i.e. to client/verifier.wasm) and runs in the browser, on the voter’s / auditor’s machine, automatically at a fixed interval.

For instructions on how to recompile it to WASM, see the README in the server/verifier folder.

How it works: Consistency proofs and Merkle Trees

  • The cryptographic verification, a.k.a the consistency proof, is achieved by leveraging the core features of immudb.
    It is based on Merkle Trees.

More details about this can be read, for example, in this article or in this one which explains the Merkle proofs.

immudb

BUILT ON THE FASTEST
IMMUTABLE LEDGER
TECHNOLOGY

Open Source and easy to use in new applications and easy to integrate into existing application.

MOST POPULAR

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials

Goal:

Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).

Implementation:

immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance

Goal:

Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.

Implementation:

While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace

Goal:

No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


Implementation:

immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data

Goal:

IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.

Implementation:

immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence

Goal:

CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.

Implementation:

As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.