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:

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


  • 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.


  • 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.