Created
December 8, 2021 23:49
-
-
Save sh4dowb/1e6b320f16791411be3fa48fe988a361 to your computer and use it in GitHub Desktop.
verify stake.com limbo outcome with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hmac | |
import hashlib | |
def getLimboOutcome(server, client, nonce): | |
server = server.encode() | |
client = client.encode() | |
nonce = str(nonce).encode() | |
round = 0 | |
hash = hmac.new(server, client+b':'+nonce+b':'+str(round).encode('utf-8'), hashlib.sha256).digest() | |
first4 = hash[:4] | |
x = 1 | |
total = 0 | |
for byt in first4: | |
total += int(byt) / (256 ** x) | |
x += 1 | |
total *= 16777216 | |
outcome = 16777216 / (total + 1) * (1 - 0.01) | |
return outcome | |
import secrets | |
server = secrets.token_hex(32) | |
client = secrets.token_urlsafe(8) | |
nonce = 1 | |
outcome = getLimboOutcome(server, client, nonce) | |
print(f"server: {server}\nclient: {client}\nnonce: {nonce}\nlimbo outcome: {outcome:.2f}x") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment