Skip to content

Conversation

@alvroble
Copy link
Contributor

@alvroble alvroble commented Oct 25, 2025

Description

SeedSigner has always reminded me of those simple handheld gaming devices we had as kids in the early 2000s. The idea of turning seed generation into a nostalgic gaming experience while actually serving a cryptographic purpose felt like a natural fit for the project's philosophy of making Bitcoin FOSS UX more approachable and engaging.

This PR adds a proof-of-concept Snake Game entropy generator, which demonstrates generating cryptographic entropy from user input. The game collects timing data from player actions to produce unpredictable entropy, turning a simple Snake game into an interactive seed generation tool.

⚠️ Important‼️: This is currently a proof-of-concept only to evaluate whether this approach is worth pursuing further. The current implementation has acknowledged limitations in entropy quality that would need significant improvements before production use. Probably crazy idea, but worth the debate.

Main features

  • Classic snake gameplay: navigate a snake to eat food on a 16x16 grid.
  • Entropy collection: captures timing intervals between user moves (400 moves total for both 12 and 24-word seeds).
  • Progress tracking: visual progress bar showing entropy collection status.
  • SHA-256 hashing: raw timing data is hashed and truncated to target entropy size (128-bit/256-bit).

Screen changes

ToolsMenuView (updated) ToolsGameEntropyMnemonicLengthView (new) ToolsGameEntropyView (new)
imagen imagen imagen

Entropy quality concerns

The current implementation has low entropy generation due to:

  • Limited randomness sources (only move timing intervals)
  • Predictable timing patterns in human gameplay
  • Insufficient entropy mixing techniques

To-do list:

  • Answer: Is there real interest in pursuing this feature further?
  • Improve entropy extraction
  • Add test flows

Include screenshots of any new or modified screens (or at least explain why they were omitted)

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

  • I’ve run pytest and made sure all unit tests pass before submitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms/os:

@alvroble
Copy link
Contributor Author

alvroble commented Oct 26, 2025

Managed to get much better (theoretically) entropy by using only time intervals between user button presses with time.time_ns(). Also compared the entropy with other sources using this code:

def byte_entropy(data: bytes) -> float:
    if not data:
        return 0.0
    counts = Counter(data)
    length = len(data)
    probs = [count / length for count in counts.values()]

    # Shannon entropy
    entropy = -sum(p * math.log2(p) for p in probs)
    return entropy

Results:

Entropy (os.urandom): 7.804983827466469
Entropy (snake game): 7.478322012474209
Entropy (seedsigner image, tried choosing a pretty random image): 7.143777631615617

Also I saw that in the SeedSigner's image etropy calculation, the image data gets chained up with other data to generate final seed. A similar approach could be taken here:

...
# Build in modest entropy via millis since power on
millis_hash = hashlib.sha256(hash_bytes + str(time.time()).encode('utf-8'))
hash_bytes = millis_hash.digest()

# Build in better entropy by chaining the preview frames
for frame in preview_images:
    img_hash = hashlib.sha256(hash_bytes + frame.tobytes())
    hash_bytes = img_hash.digest()

# Finally build in our headline entropy via the new full-res image
final_hash = hashlib.sha256(hash_bytes + seed_entropy_image.tobytes()).digest()
...

@Bicaru20
Copy link
Contributor

Hi,
I tested it in the SeedSigner emulator on Python 3.12 and 3.10, and it works perfectly.
image
image
image

I really like the idea, although I’m a bit concerned that the fruit positions might not be random enough, which could make user movements more predictable.
To improve entropy, I have a couple of ideas that popped into my head (not really sure if these would improve the entropy):

  • We could consider factoring in the final length of the snake
  • We could add a feature where pressing the joystick button randomly relocates the snake. I think this could add some entropy, although if the repositioning isn’t random enough, it could have the opposite effect. Plus, it might be a little confusing for the user.

I think this idea is worth pursuing since it gives users a fun way to create their seed.

@alvroble
Copy link
Contributor Author

@Bicaru20 Thanks for the testing!

I like your idea about including the snake length in the calculation. In general, including more elements into the entropy calculation could be good:

  • Game-related data: snake length, or even a timeline of game cycles with the direction of the movement + whether the snake ate or not, move cadence, time between deaths (currently the user never dies, snake is "transparent", but we culd change that).
  • Other data such as millis since power on (as mentioned in my previous comment) or loop timing variations.

I also like your suggestion about random repositioning. For both snake repositioning and fruit spawning, we could derive positions using a digest of the last N moves instead of relying solely on the OS RNG.

Also, I think adding more fruits to the screen would add some randomness due to the user being more frequently changing directions.

@brizbomb
Copy link

Request for optional plausible-deniability feature that would make the signer boot up to Snake game. Cheat codes entered via the game controller (referred to as "controller codes" or "controller inputs") to exit Snake to SeedSigner menu.

@alvroble
Copy link
Contributor Author

Request for optional plausible-deniability feature that would make the signer boot up to Snake game.

I agree, that would definitely be a useful feature. It’s come up in the dev TG group as well. Still, I think it’s best handled in a separate PR, since this one is focused specifically on entropy generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants