Esempio n. 1
0
 def user_provided_mnemonic(self):
     mnemonic = self.mnemonicBox.get('0.0', tk.END)
     key = HashingFunctions(None, mnemonic.rstrip())
     key.create_binary_seed()
     result_key = key.binary_seed
     self.keyBox.delete('1.0', tk.END)
     self.keyBox.insert('1.0', result_key)
Esempio n. 2
0
 def __init__(self):
     self.h = HashingFunctions()
     self.win1 = tk.Tk()
     self.win1.wm_title('Mnemonic Phrase Generator')
     self.win1.resizable(width=False, height=False)
     self.mnemonicLabel = tk.Label(self.win1, text = 'Mnemonic Phrase')
     self.mnemonicBox = tk.Text(self.win1, height=5)
     self.keyLabel = tk.Label(self.win1, text = 'binary seed')
     self.keyBox = tk.Text(self.win1, height=5)
     self.numWords = tk.StringVar()
Esempio n. 3
0
def ent_to_phrase(entropy): 
    #tests to see if provided entropy produces desired word list
    hashes = HashingFunctions()
    hashes.get_input(entropy)
    hashes.create_check_sum()
    hashes.create_word_list()
    phrase = hashes.result_word_list
    return phrase
Esempio n. 4
0
class Tests:
    def __init__(self, entropy):
        self.entropy = entropy
        self.phrase = None
        self.key = None
        self.hashes = HashingFunctions()

    def ent_to_phrase(
        self, word_list
    ):  #tests to see if provided entropy produces desired word list
        self.hashes.get_input(self.entropy)
        self.hashes.create_check_sum()
        self.hashes.create_word_list()
        self.phrase = ''.join(self.hashes.result_word_list)
        assert self.phrase == word_list

    def phrase_to_key(
        self, seed_as_hex
    ):  #tests to see if word list converts to desired master key
        self.hashes.create_binary_seed()
        self.key = self.hashes.binary_seed
        assert self.key == seed_as_hex
Esempio n. 5
0
class Display:
    #make a GUI with the following elements
    #Top box is an input box that can
    #   1. display the mnemonic phrase generated by the user
    #   2. have the user input a memonic phrase
    #Bottom left will have 2 buttons
    #   1. one button to start collecting entropy
    #   2. one button to generate mnemonic phrase and key
    #Bottom right will have a display showing master key
    def __init__(self):
        self.h = HashingFunctions()
        self.win1 = tk.Tk()
        self.win1.wm_title('Mnemonic Phrase Generator')
        self.win1.resizable(width=False, height=False)
        self.mnemonicLabel = tk.Label(self.win1, text = 'Mnemonic Phrase')
        self.mnemonicBox = tk.Text(self.win1, height=5)
        self.keyLabel = tk.Label(self.win1, text = 'binary seed')
        self.keyBox = tk.Text(self.win1, height=5)
        self.numWords = tk.StringVar()

    def user_provided_entropy(self):
        #user can decide how many words they want in their phrase
        #self.numWords = self.wordOptions.get()
        size = {'12': 128, '15': '160', '18': '192', '21':'224', '24': '256'}
        length = size[self.numWords.get()]
        ent = format(rand.randrange(1,2**int(length)), 'x')
        #bin_ent = format(ent, f'0{length}b')
        self.h.get_input(ent)
        self.h.create_check_sum()
        self.h.create_word_list()
        mnemonic = self.h.result_word_list
        self.keyBox.delete('1.0', tk.END)
        self.mnemonicBox.delete('1.0', tk.END)
        self.mnemonicBox.insert('1.0', mnemonic.rstrip())
        mnemonic = self.mnemonicBox.get('1.0', tk.END)
        self.h.create_binary_seed()
        key = self.h.binary_seed
        self.keyBox.insert('1.0', key)

    def user_provided_mnemonic(self):
        mnemonic = self.mnemonicBox.get('0.0', tk.END)
        key = HashingFunctions(None, mnemonic.rstrip())
        key.create_binary_seed()
        result_key = key.binary_seed
        self.keyBox.delete('1.0', tk.END)
        self.keyBox.insert('1.0', result_key)

    def create_dropdown(self):
        optionList = (12, 15, 18, 21, 24)
        self.numWords.set(optionList[0])
        self.wordOptions = tk.OptionMenu(self.win1, self.numWords, *optionList)


    def create_buttons(self):
        self.create_dropdown()
        self.entropyButton = tk.Button(self.win1, text = 'create mnemonic phrase', command = self.user_provided_entropy) #add command from hash class
        self.generateButton = tk.Button(self.win1, text = 'create binary seed', command = self.user_provided_mnemonic) #add create_word_list function


    def main_window(self):
        self.label = tk.Label(self.win1, text='entropy')
        self.entry = tk.Entry(self.win1, bd=5)

    def window_elements(self):
        self.mnemonicLabel.grid(row=0, column=1, columnspan=3)
        self.mnemonicBox.grid(column=1, columnspan=3, row=1, padx=10, pady=10)
        self.keyBox.grid(column=1, columnspan=3, row=1, padx=10, pady=10)
        self.entropyButton.grid(column=1, row=2)
        self.generateButton.grid(column =2, row = 2)
        self.wordOptions.grid(column=3, row=2)
        self.keyLabel.grid(column=1, columnspan=2, row=3)
        self.keyBox.grid(column=1, columnspan=2, row=4)

    def display_window(self):
        self.create_buttons()
        self.main_window()
        self.window_elements()
        self.win1.mainloop()
Esempio n. 6
0
def phrase_to_key(phrase): 
    #tests to see if word list converts to desired master key
    hashes = HashingFunctions(None, phrase)
    hashes.create_binary_seed()
    return hashes.binary_seed
Esempio n. 7
0
 def __init__(self, entropy):
     self.entropy = entropy
     self.phrase = None
     self.key = None
     self.hashes = HashingFunctions()