Announcing an updated drawing protocol for the EffectiveAltruism.org donor lotteries

bySamDeere1mo24th Jan 201913 comments

7


Update 28 Jan 2019: We've reverted to using the original NIST Beacon protocol for the draw.

It has come to our attention that the public source of randomness used to draw the EffectiveAltruism.org donor lottery — the NIST Randomness Beacon — is not currently operating due to the ongoing US government shutdown. This means our regular method of drawing winning numbers is unavailable.

Methodology

There have been several alternative methods suggested for a good public source of randomness. After careful deliberation, we have chosen to use the Incorporated Research Institutions for Seismology (IRIS) list of earthquakes as a randomness source. The data includes a range of numbers that will be impossible to predict in advance, including the latitude, longitude, magnitude, and depth of the earthquake.

We will choose the first earthquake appearing on this list of large earthquakes with a timestamp immediately after the lottery draw date.

Specifically, we will:

  • Take the numeric digits in order from the text-formatted response of the IRIS API for the relevant earthquake ID (example response)
  • Calculate the SHA256 hash of the resulting string of digits
  • Use the first 10 hexadecimal digits of the resulting SHA256 hash as the winning number

We will do the drawing at least 24 hours after the draw date to ensure that IRIS has had time to process incoming data.

There are two lotteries up for drawing ($100k and $500k), currently with draw times staggered by five minutes. In order to ensure there are two separate drawings, we will reset their draw timestamps to be identical, and then use the first two earthquake events appearing on the list after that timestamp as follows:

Worked Example

Let’s assume that the donor lotteries in question closed at midnight on January 23, 2019. The two earthquake events immediately after this timestamp are 10998501 and 10998539 respectively.

  • The ordered digits from the API response for the first earthquake are 1099850120190123013843145727667721002000743
  • The SHA256 hash of these characters is 3914a0a9b27a061c620ee651f417c4d211b218c41c089c96c8b9ad567d8c
  • The first 10 hexadecimal characters of the hash are 3914a0a9b2, which is 245159209394 in decimal
  • Therefore 245159209394 is the winning number for the first ($100k) lottery!
  • Repeating the process for the second number gives a winning number for the second ($500k) lottery of df4ceccb88/959068294024

Reference implementation

The following bash script illustrates the process for generating the hashes:

#!/bin/bash  

#  Bash script for calculating the winning lottery number using earthquake  
#  data from IRIS (Incorporated Research Institutions for Seismology).  
#  
#  Usage:  
#         ./draw_lottery_iris.sh iris_id  
#   e.g.  ./draw_lottery_iris.sh 10998811  
#  
#  The script works as follows:  
#  - get the request from the IRIS server for the relevant event  
#  - trim newlines from the response  
#  - strip the response to just the numeric digits  
#  - get the SHA256 hash of the digit string in binary  
#  - cast the binary hash to a hexdump (only keeping the first line)  
#  - truncate the hash to its first 10 characters  

EVENT_ID=$1  

curl -s "http://service.iris.edu/fdsnws/event/1/query?eventid=$EVENT_ID&format=text" \  
 | tr -d '\n' \  
 | awk '{gsub(/[^0-9]/,"")}1' \  
 | openssl dgst -sha256 -binary \  
 | xxd -p | head -n 1 \  
 | cut -c -10

Further info

To avoid any more late-breaking changes, we'll commit to using this protocol even in the event that the NIST beacon comes back online before the lottery draw date.

EDIT 28 Jan 2019: The NIST beacon has come back online. Notwithstanding the statement that we would stick with the above protocol, we've decided that it would be best to revert to the NIST Beacon as our source of randomness. That is, the drawing procedure will be as it originally was (as described in the donor lottery's methodology section).

If you have any more questions, please comment below.

Crossposted from the Centre For Effective Altruism blog

7