Skip to content

Instantly share code, notes, and snippets.

@russeree
Created August 25, 2022 05:37
Show Gist options
  • Save russeree/e9e8facda02a0139cc1aaf34cd912880 to your computer and use it in GitHub Desktop.
Save russeree/e9e8facda02a0139cc1aaf34cd912880 to your computer and use it in GitHub Desktop.
A Private Key Solver for Spirals in a 6x4 Square.
import re
import copy
import binascii
from bip_utils import (
Bip39EntropyBitLen,
Bip39EntropyGenerator,
Bip39WordsNum,
Bip39Languages,
Bip39MnemonicGenerator,
Bip39MnemonicEncoder,
MnemonicChecksumError,
Bip39Languages,
Bip39Mnemonic,
Bip39MnemonicValidator,
Bip39MnemonicDecoder
)
#Global Variables
seedPhrase = []
#Welcome Message
print(" Sprial Key Solver v.0.0.1")
print("Please enter in your 24 word seed phrase from left to right, top to bottom,")
print("Spell all seed words correct!!! This does not check for valid spelling.")
print("----------------------------------")
#Get the users seed words
for word in range(24):
seed_word = input(f'Enter Seed Word #{word + 1}: ')
seedPhrase.append(re.sub(r'\W+', ' ', seed_word))
#Create a seed phrase string from the input.
print("Your Seed Phrase Spiral Input is...")
print(seedPhrase)
print("-------------------------")
print("solving...")
#Hard coded forwards search
cwSpiral = [1,2,3,4,5,6,12,18,24,23,22,21,20,19,13,7,8,9,10,11,17,16,15,14]
ccwSpiral = [1,7,13,19,20,21,22,23,24,18,12,6,5,4,3,2,8,14,15,16,17,11,10,9]
#Variable Initialization
cwSpiralForward = []
cwSpiralReverse = []
ccwSpiralForward = []
ccwSpiralReverse = []
#Generate Seed Phrases Forward
for i in range(24):
cwSpiralForward.append(seedPhrase[cwSpiral[i] - 1])
for i in range(24):
ccwSpiralForward.append(seedPhrase[ccwSpiral[i] - 1])
#Now Reverse The Seeds Phrase Spirals
cwSpiral.reverse()
ccwSpiral.reverse()
for i in range(24):
cwSpiralReverse.append(seedPhrase[cwSpiral[i] - 1])
for i in range(24):
ccwSpiralReverse.append(seedPhrase[ccwSpiral[i] - 1])
#Print out the seed spirals
print(cwSpiralForward)
print(cwSpiralReverse)
print(ccwSpiralForward)
print(ccwSpiralReverse)
#Solve
mnemonicCwSpiralForward = Bip39Mnemonic.FromList(cwSpiralForward)
mnemonicCcwSpiralForward = Bip39Mnemonic.FromList(ccwSpiralForward)
mnemonicCwSpiralReverse = Bip39Mnemonic.FromList(cwSpiralReverse)
mnemonicCcwSpiralReverse = Bip39Mnemonic.FromList(ccwSpiralReverse)
#Break
print("RESULTS\n-----------------------")
#Spiral Solver - Rearange Seed Phrase Words from the grid and test them.
print(f'cw forward is {Bip39MnemonicValidator().IsValid(mnemonicCwSpiralForward)}')
print(f'ccw forward is {Bip39MnemonicValidator().IsValid(mnemonicCwSpiralReverse)}')
print(f'cw reverse is {Bip39MnemonicValidator().IsValid(mnemonicCcwSpiralForward)}')
print(f'ccw reverse is {Bip39MnemonicValidator().IsValid(mnemonicCcwSpiralReverse)}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment