当前位置: 首页>>代码示例>>Python>>正文


Python mnemonic.Mnemonic方法代码示例

本文整理汇总了Python中mnemonic.Mnemonic方法的典型用法代码示例。如果您正苦于以下问题:Python mnemonic.Mnemonic方法的具体用法?Python mnemonic.Mnemonic怎么用?Python mnemonic.Mnemonic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mnemonic的用法示例。


在下文中一共展示了mnemonic.Mnemonic方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_key

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def test_key():
    if not has_sha3():
        return
    m = Mnemonic("english")
    mnemonic = 'legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will'
    data = b'\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f'
    assert mnemonic == m.to_mnemonic(data)
    seed = libra_client.KeyFactory.to_seed(mnemonic)
    assert '8d8d9b85e36b2b9486becd31288e9dc2501cf77f95deb7d141eeb49d77f8a80f' == bytes.hex(seed)
    kfac = libra_client.KeyFactory(seed)
    master = bytes.hex(kfac.master)
    assert master == "16274c9618ed59177ca948529c1884ba65c57984d562ec2b4e5aa1ee3e3903be"
    child0 = kfac.private_child(0)
    assert bytes.hex(child0) == "358a375f36d74c30b7f3299b62d712b307725938f8cc931100fbd10a434fc8b9"
    child1 = kfac.private_child(1)
    assert bytes.hex(child1) == "a325fe7d27b1b49f191cc03525951fec41b6ffa2d4b3007bb1d9dd353b7e56a6"
    child0_again = kfac.private_child(0)
    assert child0_again == child0
    child1_again = kfac.private_child(1)
    assert child1_again == child1 
开发者ID:yuan-xy,项目名称:libra-client,代码行数:22,代码来源:test_key_factory.py

示例2: new

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def new(cls):
        m = Mnemonic("english")
        mnemonic = m.generate(192)
        return cls.new_from_mnemonic(mnemonic) 
开发者ID:yuan-xy,项目名称:libra-client,代码行数:6,代码来源:wallet_library.py

示例3: __init__

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def __init__(self, transport, ask_for_pin_fun, ask_for_pass_fun, passphrase_encoding):
        keepkey_TextUIMixin.__init__(self, transport)
        self.ask_for_pin_fun = ask_for_pin_fun
        self.ask_for_pass_fun = ask_for_pass_fun
        self.passphrase_encoding = passphrase_encoding
        self.__mnemonic = Mnemonic('english') 
开发者ID:Bertrand256,项目名称:dash-masternode-tool,代码行数:8,代码来源:hw_intf_keepkey.py

示例4: __init__

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def __init__(self, parent) -> None:
        QDialog.__init__(self, parent)
        ui_initialize_hw_dlg.Ui_HwInitializeDlg.__init__(self)
        WndUtils.__init__(self, parent.app_config)
        self.main_ui = parent
        self.app_config = parent.app_config
        self.current_step = STEP_SELECT_DEVICE_TYPE
        self.action_type: Optional[int] = None  # numeric value represting the action type from the first step
        self.word_count: int = 24
        self.mnemonic_words: List[str] = [""] * 24
        self.entropy: str = '' # current entropy (entered by the user or converted from mnemonic words)
        self.mnemonic = Mnemonic('english')
        self.grid_model = MnemonicModel(self, self.mnemonic_words, self.mnemonic.wordlist)
        self.address_preview_model = PreviewAddressesModel(self)
        self.hw_options_details_visible = False
        self.step_history: List[int] = []
        self.hw_type: Optional[HWType] = None  # HWType
        self.hw_model: Optional[str] = None
        self.hw_device_id_selected = Optional[str]  # device id of the hw client selected
        self.hw_device_instances: List[List[str]] = []  # list of 3-element list: 0: device_id, 1: device label, 2: device model
        self.hw_device_index_selected: int = None  # index in self.hw_device_instances
        self.act_paste_words = None
        self.hw_action_mnemonic_words: Optional[str] = None
        self.hw_action_use_pin: Optional[bool] = None
        self.hw_action_pin: Optional[str] = None
        self.hw_action_use_passphrase: Optional[bool] = None
        self.hw_action_passphrase: Optional[str] = None  # only for Ledger
        self.hw_action_secondary_pin: Optional[str] = None # only for Ledger
        self.hw_action_label: Optional[str] = None
        self.hw_firmware_source_type: int = 0  # 0: local file, 1: internet
        self.hw_firmware_source_file: str = ''
        self.hw_firmware_web_sources: List[Dict] = []
        # subset of self.hw_firmware_web_sources dedicated to current hardware wallet type:
        self.hw_firmware_web_sources_cur_hw: List = []
        self.hw_firmware_url_selected: Dict = None
        self.hw_firmware_last_hw_type = None
        self.hw_firmware_last_hw_model = None
        self.setupUi() 
开发者ID:Bertrand256,项目名称:dash-masternode-tool,代码行数:40,代码来源:initialize_hw_dlg.py

示例5: make_seed

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def make_seed(self, nbits, custom_entropy, language):
        from mnemonic import Mnemonic
        s = Mnemonic(language).make_seed(nbits, custom_entropy=custom_entropy)
        return s.encode('utf8') 
开发者ID:mazaclub,项目名称:encompass,代码行数:6,代码来源:commands.py

示例6: check_seed

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def check_seed(self, seed, custom_entropy, language):
        from mnemonic import Mnemonic
        return Mnemonic(language).check_seed(seed, custom_entropy) 
开发者ID:mazaclub,项目名称:encompass,代码行数:5,代码来源:commands.py

示例7: mnemonic_words

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def mnemonic_words(expand=False, language="english"):
    if expand:
        wordlist = Mnemonic(language).wordlist
    else:
        wordlist = set()

    def expand_word(word):
        if not expand:
            return word
        if word in wordlist:
            return word
        matches = [w for w in wordlist if w.startswith(word)]
        if len(matches) == 1:
            return word
        echo("Choose one of: " + ", ".join(matches))
        raise KeyError(word)

    def get_word(type):
        assert type == WordRequestType.Plain
        while True:
            try:
                word = prompt("Enter one word of mnemonic")
                return expand_word(word)
            except KeyError:
                pass

    return get_word 
开发者ID:bitcoin-core,项目名称:HWI,代码行数:29,代码来源:ui.py

示例8: create_share_from_wallet_words

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def create_share_from_wallet_words(self, wallet_words=None):
        (group_threshold, groups) = self.interface.enter_group_information()
        if wallet_words is None:
            wallet_words = self.interface.enter_wallet_words()
        mnemonic = Mnemonic('english')
        secret = mnemonic.to_entropy(wallet_words)

        RNG.ensure_bytes(self._needed_entropy_bytes(group_threshold, groups))
        mnemonics = shamir_share.generate_mnemonics(
            group_threshold, groups, secret)

        self._import_share_mnemonic_groups(mnemonics) 
开发者ID:unchained-capital,项目名称:hermit,代码行数:14,代码来源:shard_set.py

示例9: wallet_words

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def wallet_words(self) -> str:
        # This is a little retrograde, but at the moment, the walled code wants
        # a set of wallet words to start with. Here we are using the master
        # secret from the shamir share as the entropy that feeds into the the
        # wallet words - this is the only way that I can see that the shamir
        # code is going to be compatible with bip39 wallets.
        seed = self.secret_seed()
        mnemonic = Mnemonic('english')
        return mnemonic.to_mnemonic(seed) 
开发者ID:unchained-capital,项目名称:hermit,代码行数:11,代码来源:shard_set.py

示例10: recovery_device

# 需要导入模块: import mnemonic [as 别名]
# 或者: from mnemonic import Mnemonic [as 别名]
def recovery_device(hw_device_id: str, word_count: int, passphrase_enabled: bool, pin_enabled: bool, hw_label: str) \
        -> Tuple[str, bool]:
    """
    :param hw_device_id:
    :param passphrase_enbled:
    :param pin_enbled:
    :param hw_label:
    :return: Tuple
        [0]: Device id. If a device is wiped before initializing with mnemonics, a new device id is generated. It's
            returned to the caller.
        [1]: True, if the user cancelled the operation. In this case we deliberately don't raise the 'cancelled'
            exception, because in the case of changing of the device id (when wiping) we want to pass the new device
            id back to the caller.
    """
    mnem =  Mnemonic('english')

    def ask_for_word(type):
        nonlocal mnem
        msg = "Enter one word of mnemonic: "
        word = ask_for_word_callback(msg, mnem.wordlist)
        if not word:
            raise exceptions.Cancelled
        return word

    client = None
    try:
        client = connect_trezor(hw_device_id)

        if client:
            if client.features.initialized:
                device.wipe(client)
                hw_device_id = client.features.device_id

            device.recover(client, word_count, passphrase_enabled, pin_enabled, hw_label, language='english',
                           input_callback=ask_for_word)
            return hw_device_id, False
        else:
            raise Exception('Couldn\'t connect to Trezor device.')

    except exceptions.Cancelled:
        return hw_device_id, True

    except CancelException:
        return hw_device_id, True  # cancelled by user

    finally:
        if client:
            client.close() 
开发者ID:Bertrand256,项目名称:dash-masternode-tool,代码行数:50,代码来源:hw_intf_trezor.py


注:本文中的mnemonic.Mnemonic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。