-
Notifications
You must be signed in to change notification settings - Fork 258
[WIP] [POC] Entropy generation with snake game #820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
96ec138 to
5414308
Compare
|
Managed to get much better (theoretically) entropy by using only time intervals between user button presses with 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 entropyResults: 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 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:
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. |
|
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. |
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. |



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.
Main features
Screen changes
ToolsMenuView(updated)ToolsGameEntropyMnemonicLengthView(new)ToolsGameEntropyView(new)Entropy quality concerns
The current implementation has low entropy generation due to:
To-do list:
Include screenshots of any new or modified screens (or at least explain why they were omitted)
This pull request is categorized as a:
Checklist
pytestand made sure all unit tests pass before submitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os: