當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。