Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
Created December 8, 2021 23:49
Show Gist options
  • Save sh4dowb/1e6b320f16791411be3fa48fe988a361 to your computer and use it in GitHub Desktop.
Save sh4dowb/1e6b320f16791411be3fa48fe988a361 to your computer and use it in GitHub Desktop.
verify stake.com limbo outcome with python
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