25th word missing :-(

Try this script:

# recover.py
# written by danger_dave
# updated by Ludovit Scholtz
# Works with py-algorand-sdk:2.0.0 & python 3.10+
# run 'pip install py-algorand-sdk' to install the algosdk lib
#
# This code searches for N missing wrong words in ALGO25 mnemonic phrase with known address

from itertools import combinations, product
from algosdk import mnemonic
from algosdk import account
from algosdk import wordlist

# Write in public address
address = "JU73IC5WZRS2AF4LN6WBAY5ZFDWMNNRXU6O5VIPZIFRLLT53VHDOBYP3HQ"
# Write here the mnemonic you think you saved.. algo25 mnemonic
recovery_phrase = "journey youth journey spot increase action loyal teach rubber direct world turn blouse camp hundred vessel pottery ozone brain hard risk quiz window abstract include"
# number of words that may differ.. more words mean longer time to process.. make sure that the address is really the one for the algo25 mnemonic
word_missmatch_check = 2

word_list = wordlist.word_list_raw().split("\n")

def generate_combinations(recovery_phrase, word_list, word_missmatch_check):
    recovery_phrase = recovery_phrase.split()
    word_list = set(word_list)  # Convert to set for faster lookups

    # Ensure all recovery_phrase words are in word_list
    if not all(word in word_list for word in recovery_phrase):
        raise ValueError("All words in recovery_phrase must exist in word_list")

    # Find the indices to replace
    indices = list(range(len(recovery_phrase)))
    combinations_to_replace = combinations(indices, word_missmatch_check)

    for comb in combinations_to_replace:
        for replacements in product(sorted(word_list), repeat=word_missmatch_check):
            temp_phrase = recovery_phrase.copy()
            for idx, new_word in zip(comb, replacements):
                temp_phrase[idx] = new_word
            yield " ".join(temp_phrase)
t1 = 0
t2 = 0
# Generate and check combinations
for line in generate_combinations(recovery_phrase, word_list, word_missmatch_check):
    #print(line)
    t1=t1+1
    try:
        private_key = mnemonic.to_private_key(line)
        test_address = account.address_from_private_key(private_key)
        t2=t2+1
        if t2 % 100 == 0 :
            print(". /",t1,"/",t2, end ="\n")
        else:
            print(".", end ="")

        if test_address == address:
            print("\nFound match for specific address >>>>>>>>>>>", address)
            print(line)
            exit()
    except Exception as e:
        continue
print("\nDID NOT FIND THE PHRASE. The address differs on more then",word_missmatch_check,"words")

this one takes the 25 words and you can set how many words are wrong… so you can try to recover your mnemonic if you have 25 words you think are correct and set two words as wildcards … btw for the second word it may run quite long time, but when it finishes you get information that more then 2 words are wrong in the mnemonic

it also does some stats on the route like how many permutations it has tested and how many algo accounts were valid for those permutation

1 Like