What is Nostr?
ajrlewis
npub145d…9etj
2025-01-14 20:16:37
in reply to nevent1q…ptan

ajrlewis on Nostr: not sure ... ``` def generate_mnemonic_from_dice(roll_data: str, ...

not sure ...

```
def generate_mnemonic_from_dice(roll_data: str, wordlist_language_code: str = SettingsConstants.WORDLIST_LANGUAGE__ENGLISH) -> list[str]:
"""
Takes a string of 50 or 99 dice rolls and returns a 12- or 24-word mnemonic.

Uses the iancoleman.io/bip39 and bitcoiner.guide/seed "Base 10" or "Hex" mode approach:
* dice rolls are treated as string data.
* hashed via SHA256.

Important note: This method is NOT compatible with iancoleman's "Dice" mode.
"""
entropy_bytes = hashlib.sha256(roll_data.encode()).digest()

if len(roll_data) == DICE__NUM_ROLLS__12WORD:
# 12-word mnemonic; only use 128bits / 16 bytes
entropy_bytes = entropy_bytes[:16]

# Return as a list
return bip39.mnemonic_from_bytes(entropy_bytes, wordlist=Seed.get_wordlist(wordlist_language_code)).split()
```

https://github.com/SeedSigner/seedsigner/blob/825a25a5835bfac0fab3d84c07b3c46676348489/src/seedsigner/helpers/mnemonic_generation.py
Author Public Key
npub145dzzcseavt770mvc2xz3rvxh5w5znh3qcj8tkm3dw638m5pgwsq5q9etj