Spunk Odds Reference

Hi-lo guide

Tsunami Hi-lo: an exercise in checking cards yourself

The page is called Tsunami only because that was its original slug; the hi-lo here has no special features. Rather than describing verification, the page sets an exercise: compute three cards from given seeds on your own computer, then compare with the answer key at the bottom.

What you need

The practice inputs

Revealed server seed
tsunami-practice-seed-93
Commitment that was shown in advance
e3ea6f2072c86b8c3bc135adbf5c58179a269b24cdb7ac1014cd6e0cf3eb2c1a
Client seed
my-own-seed
Nonces to check
0, 1 and 2

Steps

  1. Hash the server seed with SHA-256 and print it as hex. Compare it character by character with the commitment above. If it differs at all, the rest of the exercise is pointless.
  2. For nonce 0, build the text my-own-seed:0:0 (client seed, nonce, round number).
  3. Compute HMAC-SHA256 with the server seed as the key and that text as the message.
  4. Take the first 8 hex digits, convert them to an integer, and divide by 4,294,967,296 (that is 2^32).
  5. Multiply by 13, round down, add 1. Write down the rank.
  6. Repeat steps 2 to 5 for nonces 1 and 2.
import hashlib, hmac
server = "tsunami-practice-seed-93"
client = "my-own-seed"
print(hashlib.sha256(server.encode()).hexdigest())
for nonce in range(3):
    msg = f"{client}:{nonce}:0".encode()
    d = hmac.new(server.encode(), msg, hashlib.sha256).hexdigest()
    u = int(d[:8], 16) / 2**32
    print(nonce, d[:8], u, int(u * 13) + 1)

The script mirrors the steps. Type it rather than pasting it if you want to be sure you understand each line. Note that int(u * 13) rounds down for positive numbers, which is all that is needed here.

Answer key

Expected results for the practice inputs
NonceFirst 8 hexFloatRank
0922f8ca90.571038058
1b804df8e0.7188243610
20566fc6c0.021102691

Computed with Python's hmac and hashlib. Floats are rounded to 8 decimals for display.

If your answer differs

Taking it further

Once the three ranks match, apply calls to them. If nonce 0 is the face card and the call is higher, nonce 1 decides it. Working through a few rounds by hand shows that verification confirms the cards; it never changes the expected loss built into the payouts.