verilot (verifiable lottery) is a command line tool for running and verifying one-time lotteries.

Related tags

Command-line verilot
Overview

verilot

verilot (verifiable lottery) is a command line tool for running and verifying one-time lotteries.

Install

Install Rust and Cargo with Rustup.

Install verilot with cargo install verilot.

Usage

The verifiable lottery process has a few overall steps.

  1. Generate secret random data and publish commitment.
  2. Gather entrants.
  3. Run lottery.
  4. Publish results (including secret random data).
  5. Users verify results.

Generating Secret

verilot generate /path/to/secret.txt > /path/to/commitment.txt

generate will write the secret bytes (hex-encoded) to the path given in the argument. It will output the commitment to stdout. We recommend publishing the commitment for the participants in your lottery to verify with.

If you publish the secret, users can use compute power to increase their chances of winning the lottery.

Running Lottery

/path/to/results.json ">
printf "foo\nbar\nbaz" | verilot lottery --secret /path/to/secret.txt > /path/to/results.json

lottery takes the list of entrants as newline-separated arbitrary strings as input on stdin. It outputs a json structure with the outcome to stdout. The whole json file should be published for entrants to verify fairness.

The output contains a field of the entrants in order of hash value. Winners are the entrants with the lowest hash value.

Example output:

{
  "ordered_entries": [
    {
      "entrant": "baz",
      "ticket": "030b0be9796353fbadd6d4acb1883551f016b30316b7510b1525642689b9f32c3ada75bb4ba005a4abcf61a8e09ec0c8a2410a0415d0a9642e08b622290a49c8"
    },
    {
      "entrant": "bar",
      "ticket": "4bd8e47093eec63086e4c1f3dc717b4c7724e96b30ff1aa5b498dc1eec8fae461eb81dd6ecedb208bc166f50dc260c9e9f60d3a2cf1e8a15a8f3cba36fd3b247"
    },
    {
      "entrant": "foo",
      "ticket": "9f846275d1b9f2eb9e4c7e830ff33f075c38b7ae84ae8eabe9c4a04ec026ff4bb443b57a5324c0f498adf98c2a5fd35cd638381eaa784ae262248d3e084b1f8e"
    }
  ],
  "secret": [
    43, 59, 138, 218, 23, 151, 103, 84,
    227, 162, 246, 113, 150, 225, 237, 223,
    14, 248, 110, 47, 197, 241, 70, 196,
    213, 113, 253, 230, 211, 167, 112, 94,
    150, 108, 15, 99, 237, 129, 217, 131,
    138, 198, 202, 144, 131, 242, 157, 17,
    46, 14, 55, 107, 185, 58, 38, 40,
    64, 139, 62, 107, 234, 215, 85, 237
  ]
}

Hashing Input

Since it's common to not want to publish the raw entrant input strings (which is required for verifying fairness), we provide a subcommand to hash raw input strings.

printf "foo\nbar\nbaz" | verilot digest

# Output:
# abcdef... "foo"
# abcdef... "bar"
# abcdef... "baz"

You can then easily split out the hash with cut -f1 -d' '. You'll need to manually pair the hashes in the results with the output of digest to get the appropriate winners.

Verifying

cat /path/to/results.json | verilot verify --commitment "abcdef"

verify takes the json results of the lottery as input on stdin. It optionally takes the commitment as hex string. Verify will exit with a non-zero code if the verification fails.

Algorithm

Each entrant gets a "ticket" calculated as Hash(entrant_data | secret). Winners are the entrants with the lowest tickets.

verilot uses Blake2b for all hashing. generate generates secrets with 512 bits of randomness from the OS's secure pRNG. See https://docs.rs/rand/0.8.4/rand/rngs/struct.ThreadRng.html for more details.

You might also like...
An implementation of Verifiable Delay Functions in Rust

Verifiable Delay Function (VDF) Implementation in Rust What is a VDF? A Verifiable Delay Function (VDF) is a function that requires substantial time t

it aims to augment git with primitives to build integrated, cryptographically verifiable collaboration workflows around source code

it aims to augment git with primitives to build integrated, cryptographically verifiable collaboration workflows around source code. It maintains the distributed property of git, not requiring a central server. it is transport agnostic, and permits data dissemination in client-server, federated, as well as peer-to-peer network topologies.

Pink is a command-line tool inspired by the Unix man command.

Pink is a command-line tool inspired by the Unix man command. It displays custom-formatted text pages in the terminal using a subset of HTML-like tags.

A command line tool written in Rust and designed to be a modern build tool + package manager for C/C++ projects.

CCake CCake is a command line tool written in Rust and designed to be a modern build tool + package manager for C/C++ projects. Goals To be easily und

zman is a CLI year (time) progress that small, fast, and just one single binary.
zman is a CLI year (time) progress that small, fast, and just one single binary.

zman zman is a CLI year (time) progress that small, fast, and just one single binary. Features Show year progress Show month, and week progress Show r

Real-time stock tickers from the command-line. Written in Rust.

ticker-rs Real-time stock tickers from the command-line written in Rust. CLI tool using the Yahoo Finance API as a data source. It features colored ou

Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.

Rust FileOps Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're w

🐴 RusTOTPony — CLI manager of one-time password generators aka Google Authenticator

🐴 RusTOTPony CLI manager of time-based one-time password generators. It is a desktop alternative for Google Authenticator. Installation Arch Linux Pa

💾Saving Your Hard Disk, One Project at a Time
💾Saving Your Hard Disk, One Project at a Time

nodemore 💾 Nodemore Recursively Searches Directories for Unused Projects Contents Why? Installation Usage Configuration Why? NodeJS has a horrible wa

Owner
Shelby Doolittle
Shelby Doolittle
A super simple /sbin/init for Linux which allows running one and only one program

Summary High-performance /sbin/init program for Linux This is designed to do literally nothing but accept binaries over the network and run them as a

null 19 Dec 4, 2023
A command-line tool to easily kill processes running on a specified port.

killport killport is a command-line utility for killing processes listening on specific ports. It's designed to be simple, fast, and effective. The to

Francisco Jiménez Cabrera 6 Mar 29, 2023
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
belt is a command line app that can show your time from a list of selected time zones

A CLI app to show your time from a list of selected time zones, and a rust lib to parse dates in string formats that are commonly used.

Rollie Ma 23 Nov 4, 2022
KAIVM is a multiplatform Command Line Interface (CLI) designed to simplify the process of downloading, managing, configuring, and running different versions of Shinkai Node

KAIVM - Shinkai Version Manager KAIVM is a multiplatform Command Line Interface (CLI) designed to simplify the process of downloading, managing, confi

Alfredo Gallardo 7 May 1, 2024
Works out if this is running from inside a shell, and if so, which one.

pshell pshell answers the question "Is my application running in a shell, and if so, which one". Example: you are installing something and want to mak

Alec Brown 2 Nov 3, 2022
⌚ A command-line tool (and library) for the rusty Swatch Internet Time.

⌚ A command-line tool (and library) for the rusty Swatch Internet Time. Comes with XBar/Swiftbar support.

Gil Desmarais 4 Jul 18, 2022
Bartib is an easy to use time tracking tool for the command line.

Bartib is an easy to use time tracking tool for the command line. It saves a log of all tracked activities as a plaintext file and allows you to create flexible reports.

Nikolas Schmidt-Voigt 346 Jan 2, 2023
Verifiable and confidential computation based on ZKP and FHE, powered by risc0 zkVM.

zkFHE Verifiable and confidential computation based on ZKP and FHE, powered by risc0 zkVM. A PoC to demonstrate an approach for private computation on

Emiliano Bonassi 29 Apr 25, 2023