def test_bip39(language: str, test: Sequence[str]) -> None:
    test_entropy = bytes.fromhex(test[0])
    test_mnemonic = test[1]
    test_seed = bytes.fromhex(test[2])

    assert get_mnemonic(language=language,
                        words_path=WORD_LISTS_PATH,
                        entropy=test_entropy) == test_mnemonic
    assert get_seed(mnemonic=test_mnemonic, password='******') == test_seed
Exemple #2
0
def test_bip39(language, language_test_vectors):
    for test in language_test_vectors:
        test_entropy = bytes.fromhex(test[0])
        test_mnemonic = test[1]
        test_seed = bytes.fromhex(test[2])

        assert get_mnemonic(language=language,
                            words_path=WORD_LISTS_PATH,
                            entropy=test_entropy) == test_mnemonic
        assert get_seed(mnemonic=test_mnemonic, password='******') == test_seed
Exemple #3
0
def generate_mnemonic(language: str, words_path: str) -> str:
    mnemonic = get_mnemonic(language=language, words_path=words_path)
    test_mnemonic = ''
    while mnemonic != test_mnemonic:
        click.clear()
        click.echo('This is your seed phrase. Write it down and store it safely, it is the ONLY way to retrieve your deposit.')  # noqa: E501
        click.echo('\n\n%s\n\n' % mnemonic)
        click.pause('Press any key when you have written down your mnemonic.')

        click.clear()
        test_mnemonic = click.prompt('Please type your mnemonic (separated by spaces) to confirm you have written it down\n\n')  # noqa: E501
        test_mnemonic = test_mnemonic.lower()
    click.clear()
    return mnemonic
Exemple #4
0
def new_mnemonic(ctx: click.Context, mnemonic_language: str,
                 **kwargs: Any) -> None:
    mnemonic = get_mnemonic(language=mnemonic_language,
                            words_path=WORD_LISTS_PATH)
    test_mnemonic = ''
    while mnemonic != test_mnemonic:
        click.clear()
        click.echo(
            'This is your seed phrase. Write it down and store it safely, it is the ONLY way to retrieve your deposit.'
        )  # noqa: E501
        click.echo('\n\n%s\n\n' % mnemonic)
        click.pause('Press any key when you have written down your mnemonic.')

        click.clear()
        test_mnemonic = click.prompt(
            'Please type your mnemonic (separated by spaces) to confirm you have written it down\n\n'
        )  # noqa: E501
        test_mnemonic = test_mnemonic.lower()
    click.clear()
    # Do NOT use mnemonic_password.
    ctx.obj = {'mnemonic': mnemonic, 'mnemonic_password': ''}
    ctx.params['validator_start_index'] = 0
    ctx.forward(generate_keys)