From 249929dab2b4479a3d295bba1477476d0f90c511 Mon Sep 17 00:00:00 2001 From: shironeko Date: Sun, 15 Nov 2020 14:47:09 +0800 Subject: [PATCH] update readme --- README.md | 58 +++++++++++++++++++++++++++++++-------------------- example.txt | 2 +- lotte-cli.scm | 1 + 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d8d5275..7f48c4c 100644 --- a/README.md +++ b/README.md @@ -6,47 +6,59 @@ This is still a proof of concept lotte needs `guile` and `guile-gcrypt` ## Usage: -Create a file like below, let's call it `example.txt`, bracketed text are -comments. No trailing spaces anywhere please. :) +To start a lottery, run ``` -shironeko's 1st Test Lottery (Name needs to be differen each time) -42 (This is the lucky number, don't reveal it until the end, bigger is probably better) +./lotte-cli.scm some-name ``` -Then run +This will create a text file called `some-name.txt` with the info you are about +to provide (if you didn't give it a name, it will create one with a random +name). Fill them in like below, and it should tell you want you need to post in +your lottery. ``` -cat example.txt | ./lotte.scm +Enter the name of your lottery (needs to be unique each time): shironeko's 1st Test Lottery +Enter your lucky number: 42 +Enter the number of winners: 2 +The info you need to post: +shironeko's 1st Test Lottery +Lucky number's MAC: rYIpZz6lb4OmdGXWAWCpS39cSgCpk5El1ep-b0JGtDs= +Number of Winners: 2 ``` -the output shows your sealed lucky number, post it along with your announcement -to prove you didn't change the lucky number afterwards, you need to save the -key somewhere for that. +The generated file should look like this ``` -Your sealed lucky number is: 1617e076355f986242d59e15e51425c7fdee4b1c3227c9bfb0718f137a7af987 -The key is: 31d3b2bd349f49c82c273fde55af55ac7ee1d8fbca49fd46857b639eb735a5d3 (reveal this at the end) +shironeko's 1st Test Lottery +42 +2 +8KwDCd16chFZUw0YWmSOpEWYNqco3YKb2wXt8-nJdDE= ``` -Then add users one by one like so +Then add users one by one like so, make sure to not have any trailing spaces ``` shironeko's 1st Test Lottery 42 +2 +8KwDCd16chFZUw0YWmSOpEWYNqco3YKb2wXt8-nJdDE= myself -@someone +somebody@school idon't really know this guy -a🐈️ +🐈️🐈️🐈️🐈️🐈️🐈️🐈️🐈️ ``` -and run the same command again +To draw the winners, run ``` -cat example.txt | ./lotte.scm +./lotte-cli.scm some-name.txt ``` -lotte should output the winner along with their score. +lotte should output the winner, their score, and all the other info you need to +post. ``` -The winner is: myself -Their score is: 001b6c8ebff639c529feea5115754b56c1b2f29e201f35f5c718a1efdff6f4a8 +The winners are: +myself score: 001b6c8ebff639c529feea5115754b56c1b2f29e201f35f5c718a1efdff6f4a8 +🐈️🐈️🐈️🐈️🐈️🐈️🐈️🐈️ score: 0502b2bc4e4e79f3cdbe530be27608d2becd2b0d5bc21f166ddc59a40945d835 +The lucky number is: 42 +The MAC key is: 8KwDCd16chFZUw0YWmSOpEWYNqco3YKb2wXt8-nJdDE= ``` -Don't forget to tell everyone the lottery name and the lucky number you used in -the file and the key saved from before when you announce the winner. other -users can use those to calculate their own score, and they can verifiy that -nothing fishy (heh) is going on. +Participants can use those to calculate their own score, and they can verifiy +that nothing fishy (heh) is going on (lowest score wins). ``` score = min(sha256(1 ),...,sha256( )) +mac = hmac-sha256(mac-key, lucky-number-str) ``` # License diff --git a/example.txt b/example.txt index 9298350..00718ed 100644 --- a/example.txt +++ b/example.txt @@ -1,7 +1,7 @@ shironeko's 1st Test Lottery 42 2 -jJJ7QZXuaaFrsPGz1H4Gcua7v2qd5I1SOkn_uaxr5pU= +8KwDCd16chFZUw0YWmSOpEWYNqco3YKb2wXt8-nJdDE= myself somebody@school idon't really know this guy diff --git a/lotte-cli.scm b/lotte-cli.scm index 5e35e35..dfef3b5 100755 --- a/lotte-cli.scm +++ b/lotte-cli.scm @@ -81,4 +81,5 @@ (let ((winners (lotte lotte-name lucky-num num-of-winners users))) (display "The winners are:\n") (print-winners winners) + (format #t "The lucky number is: ~A\n" lucky-num-str) (format #t "The MAC key is: ~A\n" mac-key)))))) -- 2.45.2