Thread: Digital Dice
View Single Post
Old 12-08-2017, 02:41 PM   #23
darkmorgoth
Senior Member
 
darkmorgoth's Avatar
 
Join Date: Jun 2013
Location: Europe
Posts: 109
Blog Entries: 3
Default

There's a good way to securely roll a die between two persons without requiring any websites or emails if you have access to a linux shell:

1. Alice picks a decently sized random number, i.e. with:
Code:
$ dd if=/dev/urandom bs=8 count=1 status=none | xxd -ps
4b3bde518f53e97f
2. She generates a cryptographic hash of that number and sends it to Bob:
Code:
$ echo 4b3bde518f53e97f | sha256sum
89dbb80685382fd0e40deefa55274b6598bf07b198c27ec9435157c6231f228e  -
3. Bob generates a random number and sends it to Alice:
Code:
$ dd if=/dev/urandom bs=8 count=1 status=none | xxd -ps
66ea8ac179e39753
4. Alice reveals her number from step 1

5. Bob verifies its checksum is OK

6. They XOR the two random numbers and take a modulus of whatever-many sides they want. Assuming they want a d6:
Code:
$ echo $(( (0x4b3bde518f53e97f ^ 0x66ea8ac179e39753) % 6 + 1))
1
They rolled a 1. Yay.

Edit: There's also quite a few websites that can calculate XOR or SHA256 for you. You can also get a shell in your browser: https://bellard.org/jslinux/vm.html?...ldroot-x86.cfg (it's missing xxd, so change "xxd -ps" to "od -A n -t x8")
__________________
32/m/switch

Last edited by darkmorgoth; 12-08-2017 at 02:53 PM. Reason: Add a note about websites
darkmorgoth is offline   Reply With Quote