コード例 #1
0
    def test_sign_utf(self):
        self.setup_mnemonic_nopin_nopassphrase()

        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(
            self.client,
            "Bitcoin",
            [0],
            words_nfkd,
            script_type=proto.InputScriptType.SPENDP2SHWITNESS,
        )
        assert sig_nfkd.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
        assert (
            sig_nfkd.signature.hex()
            == "24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )

        sig_nfc = btc.sign_message(
            self.client,
            "Bitcoin",
            [0],
            words_nfc,
            script_type=proto.InputScriptType.SPENDP2SHWITNESS,
        )
        assert sig_nfc.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
        assert (
            sig_nfc.signature.hex()
            == "24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )
コード例 #2
0
    def test_sign_utf(self, client):
        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(
            client,
            "Bitcoin",
            [0],
            words_nfkd,
            script_type=proto.InputScriptType.SPENDP2SHWITNESS,
        )
        assert sig_nfkd.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
        assert (
            sig_nfkd.signature.hex() ==
            "24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )

        sig_nfc = btc.sign_message(
            client,
            "Bitcoin",
            [0],
            words_nfc,
            script_type=proto.InputScriptType.SPENDP2SHWITNESS,
        )
        assert sig_nfc.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
        assert (
            sig_nfc.signature.hex() ==
            "24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )
コード例 #3
0
    def test_sign_utf(self):
        self.setup_mnemonic_nopin_nopassphrase()

        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(
            self.client,
            "Bitcoin",
            [0],
            words_nfkd,
            script_type=proto.InputScriptType.SPENDWITNESS,
        )
        assert sig_nfkd.address == "bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j"
        assert (
            hexlify(sig_nfkd.signature)
            == b"28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )

        sig_nfc = btc.sign_message(
            self.client,
            "Bitcoin",
            [0],
            words_nfc,
            script_type=proto.InputScriptType.SPENDWITNESS,
        )
        assert sig_nfc.address == "bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j"
        assert (
            hexlify(sig_nfc.signature)
            == b"28d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )
コード例 #4
0
 def test_sign_message(self, client):
     with client:
         client.set_expected_responses([
             proto.ButtonRequest(),
             proto.PinMatrixRequest(),
             proto.PassphraseRequest(),
             proto.MessageSignature(),
         ])
         btc.sign_message(client, "Bitcoin", [], "testing message")
コード例 #5
0
 def test_sign_message(self):
     with self.client:
         self.setup_mnemonic_pin_passphrase()
         self.client.set_expected_responses([
             proto.ButtonRequest(),
             proto.PinMatrixRequest(),
             proto.PassphraseRequest(),
             proto.MessageSignature(),
         ])
         btc.sign_message(self.client, "Bitcoin", [], "testing message")
コード例 #6
0
 def test_sign_message(self, client):
     with client:
         client.use_pin_sequence([PIN4])
         client.set_expected_responses([
             messages.ButtonRequest,
             messages.PinMatrixRequest,
             messages.PassphraseRequest,
             messages.MessageSignature,
         ])
         btc.sign_message(client, "Bitcoin", [], "testing message")
コード例 #7
0
def test_signmessage_pagination_trailing_newline(client):
    # This can currently only be tested by a human via the UI test diff:
    message = "THIS\nMUST\nNOT\nBE\nPAGINATED\n"
    # The trailing newline must not cause a new paginated screen to appear.
    # The UI must be a single dialog without pagination.
    btc.sign_message(
        client,
        coin_name="Bitcoin",
        n=parse_path("m/44h/0h/0h/0/0"),
        message=message,
    )
コード例 #8
0
def test_sign_message_t2(client):
    _assert_protection(client)
    with client:
        client.use_pin_sequence([PIN4])
        client.set_expected_responses([
            _pin_request(client),
            messages.PassphraseRequest,
            messages.ButtonRequest,
            messages.MessageSignature,
        ])
        btc.sign_message(client, "Bitcoin", parse_path("44h/0h/0h/0/0"),
                         "testing message")
コード例 #9
0
 def test_sign_message(self):
     with self.client:
         self.setup_mnemonic_pin_passphrase()
         self.client.set_expected_responses(
             [
                 proto.ButtonRequest(),
                 proto.PinMatrixRequest(),
                 proto.PassphraseRequest(),
                 proto.MessageSignature(),
             ]
         )
         btc.sign_message(self.client, "Bitcoin", [], "testing message")
コード例 #10
0
def sign_message(hw_session: HwSessionInfo, bip32path, message):
    client = hw_session.hw_client
    address_n = dash_utils.bip32_path_string_to_n(bip32path)
    try:
        return btc.sign_message(client, hw_session.app_config.hw_coin_name, address_n, message)
    except exceptions.Cancelled:
        raise CancelException('Cancelled')
コード例 #11
0
def test_signmessage_pagination_trailing_newline(client):
    message = "THIS\nMUST\nNOT\nBE\nPAGINATED\n"
    # The trailing newline must not cause a new paginated screen to appear.
    # The UI must be a single dialog without pagination.
    with client:
        client.set_expected_responses([
            # expect a ButtonRequest that does not have pagination set
            message_filters.ButtonRequest(pages=None),
            messages.MessageSignature,
        ])
        btc.sign_message(
            client,
            coin_name="Bitcoin",
            n=parse_path("m/44h/0h/0h/0/0"),
            message=message,
        )
コード例 #12
0
 def test_sign_long(self, client):
     sig = btc.sign_message(client, "Bitcoin", [0], "VeryLongMessage!" * 64)
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         sig.signature.hex() ==
         "205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )
コード例 #13
0
def test_signmessage_pagination(client, message):
    message_read = ""
    message += "End."

    def input_flow():
        # collect screen contents into `message_read`.
        # Join lines that are separated by a single "-" string, space-separate lines otherwise.
        nonlocal message_read

        yield
        # start assuming there was a word break; this avoids prepending space at start
        word_break = True
        max_attempts = 100
        while max_attempts:
            layout = client.debug.wait_layout()
            for line in layout.lines[1:]:
                if line == "-":
                    # next line will be attached without space
                    word_break = True
                elif word_break:
                    # attach without space, reset word_break
                    message_read += line
                    word_break = False
                else:
                    # attach with space
                    message_read += " " + line

            if not message_read.endswith("End."):
                client.debug.swipe_up()
            else:
                client.debug.press_yes()
                break

            max_attempts -= 1

        assert max_attempts > 0, "failed to scroll through message"

    with client:
        client.set_input_flow(input_flow)
        client.debug.watch_layout(True)
        btc.sign_message(
            client,
            coin_name="Bitcoin",
            n=parse_path("m/44h/0h/0h/0/0"),
            message=message,
        )
    assert message.replace("\n", " ") == message_read
コード例 #14
0
    def test_sign_utf(self, client):
        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(client, "Bitcoin", [0], words_nfkd)
        assert sig_nfkd.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
        assert (
            sig_nfkd.signature.hex() ==
            "20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )

        sig_nfc = btc.sign_message(client, "Bitcoin", [0], words_nfc)
        assert sig_nfc.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
        assert (
            sig_nfc.signature.hex() ==
            "20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )
コード例 #15
0
 def test_sign_grs(self, client):
     sig = btc.sign_message(client, "Groestlcoin",
                            parse_path("44'/17'/0'/0/0"), "test")
     assert sig.address == "Fj62rBJi8LvbmWu2jzkaUX1NFXLEqDLoZM"
     assert (
         base64.b64encode(sig.signature) ==
         b"INOYaa/jj8Yxz3mD5k+bZfUmjkjB9VzoV4dNG7+RsBUyK30xL7I9yMgWWVvsL46C5yQtxtZY0cRRk7q9N6b+YTM="
     )
コード例 #16
0
 def test_sign_bch(self, client):
     sig = btc.sign_message(client, "Bcash", [0],
                            "This is an example of a signed message.")
     assert sig.address == "bitcoincash:qqj22md58nm09vpwsw82fyletkxkq36zxyxh322pru"
     assert (
         sig.signature.hex() ==
         "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #17
0
 def test_sign_testnet(self, client):
     sig = btc.sign_message(client, "Testnet", [0],
                            "This is an example of a signed message.")
     assert sig.address == "mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL"
     assert (
         sig.signature.hex() ==
         "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #18
0
 def test_sign(self, client):
     sig = btc.sign_message(client, "Bitcoin", [0],
                            "This is an example of a signed message.")
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         sig.signature.hex() ==
         "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #19
0
 def test_sign_long(self, client):
     address_n = parse_path("m/44'/42'/0'/0/0")
     sig = btc.sign_message(client, "Decred", address_n, "VeryLongMessage!" * 64)
     assert sig.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
     assert (
         sig.signature.hex()
         == "1f4ce0f81b387d6c9ce3961baf9ae10c2fe14a2d13243ec5863131d526c77d4459636ba71217a47726ecf7517bde41e3ef95a3de10054ff88bbf8ca5cb0b5f3cea"
     )
コード例 #20
0
 def test_sign_long(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(self.client, "Bitcoin", [0], "VeryLongMessage!" * 64)
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         sig.signature.hex()
         == "205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )
コード例 #21
0
def test_signmessage_pagination(client: Client, message):
    message_read = ""

    def input_flow():
        # collect screen contents into `message_read`.
        # Join lines that are separated by a single "-" string, space-separate lines otherwise.
        nonlocal message_read

        # confirm address
        br = yield
        layout = client.debug.wait_layout()
        client.debug.press_yes()

        # start assuming there was a word break; this avoids prepending space at start
        word_break = True
        br = yield
        for i in range(br.pages):
            layout = client.debug.wait_layout()
            for line in layout.lines[1:]:
                if line == "-":
                    # next line will be attached without space
                    word_break = True
                elif word_break:
                    # attach without space, reset word_break
                    message_read += line
                    word_break = False
                else:
                    # attach with space
                    message_read += " " + line

            if i < br.pages - 1:
                client.debug.swipe_up()

        client.debug.press_yes()

    with client:
        client.set_input_flow(input_flow)
        client.debug.watch_layout(True)
        btc.sign_message(
            client,
            coin_name="Bitcoin",
            n=parse_path("m/44h/0h/0h/0/0"),
            message=message,
        )
    assert "Confirm message:   " + message.replace("\n", " ") == message_read
コード例 #22
0
 def test_sign_mainnet(self, client):
     address_n = parse_path("m/44'/42'/0'/0/0")
     sig = btc.sign_message(client, "Decred", address_n,
                            "This is an example of a signed message.")
     assert sig.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
     assert (
         sig.signature.hex() ==
         "20417ee6116304a65d267aec989a1450ed3699201cc0f2a6e8273a3ad31dfb3cda26a5b26f040aa3d0d76c66d6d7c1d1e5e424c1298b3ba1201c36a0a87971ed83"
     )
コード例 #23
0
 def test_sign_long(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(self.client, "Bitcoin", [0],
                            "VeryLongMessage!" * 64)
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         hexlify(sig.signature) ==
         b"205ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )
コード例 #24
0
 def test_sign_testnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(self.client, "Testnet", [0],
                            "This is an example of a signed message.")
     assert sig.address == "mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL"
     assert (
         hexlify(sig.signature) ==
         b"209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #25
0
 def test_sign(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(self.client, "Bitcoin", [0],
                            "This is an example of a signed message.")
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         hexlify(sig.signature) ==
         b"209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #26
0
    def test_sign_utf(self, client):
        address_n = parse_path("m/44'/42'/0'/0/0")

        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(client, "Decred", address_n, words_nfkd)
        assert sig_nfkd.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
        assert (
            sig_nfkd.signature.hex()
            == "1feb2e6eeabe6508fff655c7c3aa7b52098b09e01c9f0cfae404bd4d7baf856e762b72a4c13a8f826b7a42c0b48a5a1b12a96497ca90bd2b183e42f4b3d4eea16b"
        )

        sig_nfc = btc.sign_message(client, "Decred", address_n, words_nfc)
        assert sig_nfc.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
        assert (
            sig_nfc.signature.hex()
            == "1feb2e6eeabe6508fff655c7c3aa7b52098b09e01c9f0cfae404bd4d7baf856e762b72a4c13a8f826b7a42c0b48a5a1b12a96497ca90bd2b183e42f4b3d4eea16b"
        )
コード例 #27
0
 def test_sign_testnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client, "Testnet", [0], "This is an example of a signed message."
     )
     assert sig.address == "mirio8q3gtv7fhdnmb3TpZ4EuafdzSs7zL"
     assert (
         sig.signature.hex()
         == "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #28
0
 def test_sign(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client, "Bitcoin", [0], "This is an example of a signed message."
     )
     assert sig.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
     assert (
         sig.signature.hex()
         == "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #29
0
ファイル: trezorClient.py プロジェクト: PIVX-Project/PET4L
 def signMessageSign(self, ctrl, path, mess, isTestnet):
     self.signature = None
     if isTestnet:
         hw_coin = "PIVX Testnet"
     else:
         hw_coin = "PIVX"
     with self.lock:
         bip32_path = parse_path(path)
         signed_mess = btc.sign_message(self.client, hw_coin, bip32_path, mess)
         self.signature = signed_mess.signature
コード例 #30
0
    def test_sign_utf(self):
        self.setup_mnemonic_nopin_nopassphrase()

        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(self.client, "Bitcoin", [0], words_nfkd)
        assert sig_nfkd.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
        assert (
            sig_nfkd.signature.hex()
            == "20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )

        sig_nfc = btc.sign_message(self.client, "Bitcoin", [0], words_nfc)
        assert sig_nfc.address == "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e"
        assert (
            sig_nfc.signature.hex()
            == "20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6"
        )
コード例 #31
0
 def test_sign_grs(self):
     self.setup_mnemonic_allallall()
     sig = btc.sign_message(
         self.client, "Groestlcoin", parse_path("44'/17'/0'/0/0"), "test"
     )
     assert sig.address == "Fj62rBJi8LvbmWu2jzkaUX1NFXLEqDLoZM"
     assert (
         base64.b64encode(sig.signature)
         == b"INOYaa/jj8Yxz3mD5k+bZfUmjkjB9VzoV4dNG7+RsBUyK30xL7I9yMgWWVvsL46C5yQtxtZY0cRRk7q9N6b+YTM="
     )
コード例 #32
0
 def test_sign_bch(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client, "Bcash", [0], "This is an example of a signed message."
     )
     assert sig.address == "bitcoincash:qqj22md58nm09vpwsw82fyletkxkq36zxyxh322pru"
     assert (
         sig.signature.hex()
         == "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #33
0
def test_signmessage(client, coin_name, path, script_type, address, message, signature):
    sig = btc.sign_message(
        client,
        coin_name=coin_name,
        n=parse_path(path),
        script_type=script_type,
        message=message,
    )
    assert sig.address == address
    assert sig.signature.hex() == signature
コード例 #34
0
 def sign_message(self, required_data):
     sig = btc.sign_message(self.client, "Bitcoin", required_data['path'],
                            required_data['message'])
     # TODO: trezor appears to generate a recoverable sig
     sig_der = wally.ec_sig_to_der(sig['signature'][1:])
     return json.dumps({
         'signature':
         sig_der.hex(),
         'signature_b64':
         base64.b64encode(sig['signature']).decode('ascii')
     })
コード例 #35
0
 def test_sign_long(self):
     self.setup_mnemonic_nopin_nopassphrase()
     address_n = parse_path("m/44'/42'/0'/0/0")
     sig = btc.sign_message(
         self.client, "Decred", address_n, "VeryLongMessage!" * 64
     )
     assert sig.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
     assert (
         sig.signature.hex()
         == "1f4ce0f81b387d6c9ce3961baf9ae10c2fe14a2d13243ec5863131d526c77d4459636ba71217a47726ecf7517bde41e3ef95a3de10054ff88bbf8ca5cb0b5f3cea"
     )
コード例 #36
0
def sign_message(hw_client, hw_coin_name: str, bip32path: str, message: str):
    address_n = dash_utils.bip32_path_string_to_n(bip32path)
    try:
        return btc.sign_message(hw_client, hw_coin_name, address_n, message)
    except exceptions.Cancelled:
        raise CancelException('Cancelled')
    except exceptions.TrezorFailure as e:
        if e.failure.message == 'Device not initialized':
            raise HwNotInitialized(e.failure.message)
        else:
            raise
コード例 #37
0
def test_signmessage(client: Client, path, script_types):
    for script_type in script_types:
        sig = btc.sign_message(
            client,
            coin_name="Bitcoin",
            n=parse_path(path),
            script_type=script_type,
            message="This is an example of a signed message.",
        )

        assert sig.signature
コード例 #38
0
 def test_sign_mainnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     address_n = parse_path("m/44'/42'/0'/0/0")
     sig = btc.sign_message(
         self.client, "Decred", address_n, "This is an example of a signed message."
     )
     assert sig.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
     assert (
         sig.signature.hex()
         == "20417ee6116304a65d267aec989a1450ed3699201cc0f2a6e8273a3ad31dfb3cda26a5b26f040aa3d0d76c66d6d7c1d1e5e424c1298b3ba1201c36a0a87971ed83"
     )
コード例 #39
0
    def test_sign_utf(self):
        self.setup_mnemonic_nopin_nopassphrase()
        address_n = parse_path("m/44'/42'/0'/0/0")

        words_nfkd = u"Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a"
        words_nfc = u"P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f"

        sig_nfkd = btc.sign_message(self.client, "Decred", address_n, words_nfkd)
        assert sig_nfkd.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
        assert (
            sig_nfkd.signature.hex()
            == "1feb2e6eeabe6508fff655c7c3aa7b52098b09e01c9f0cfae404bd4d7baf856e762b72a4c13a8f826b7a42c0b48a5a1b12a96497ca90bd2b183e42f4b3d4eea16b"
        )

        sig_nfc = btc.sign_message(self.client, "Decred", address_n, words_nfc)
        assert sig_nfc.address == "DsbjnfJrnL1orxJBCN8Kf39NjMwEktdfdWy"
        assert (
            sig_nfc.signature.hex()
            == "1feb2e6eeabe6508fff655c7c3aa7b52098b09e01c9f0cfae404bd4d7baf856e762b72a4c13a8f826b7a42c0b48a5a1b12a96497ca90bd2b183e42f4b3d4eea16b"
        )
コード例 #40
0
def test_signmessage_path_warning(client):
    message = "This is an example of a signed message."

    with client:
        client.set_expected_responses([
            # expect a path warning
            message_filters.ButtonRequest(
                code=messages.ButtonRequestType.UnknownDerivationPath),
            message_filters.ButtonRequest(
                code=messages.ButtonRequestType.Other),
            message_filters.ButtonRequest(
                code=messages.ButtonRequestType.Other),
            messages.MessageSignature,
        ])
        btc.sign_message(
            client,
            coin_name="Bitcoin",
            n=parse_path("m/86h/0h/0h/0/0"),
            message=message,
            script_type=messages.InputScriptType.SPENDWITNESS,
        )
コード例 #41
0
 def test_sign_long(self, client):
     sig = btc.sign_message(
         client,
         "Bitcoin",
         [0],
         "VeryLongMessage!" * 64,
         script_type=proto.InputScriptType.SPENDWITNESS,
     )
     assert sig.address == "bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j"
     assert (
         sig.signature.hex() ==
         "285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )
コード例 #42
0
 def test_sign_testnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     address_n = parse_path("m/44'/1'/0'/0/0")
     sig = btc.sign_message(
         self.client,
         "Decred Testnet",
         address_n,
         "This is an example of a signed message.",
     )
     assert sig.address == "TsRQTRqf5TdEfqsnJ1gcQEDvPP363cEjr4B"
     assert (
         sig.signature.hex()
         == "20260e5665cca98e0a08ebf33346a0e1cdb7ef313d0c50d1403f5c1ea7ef5958204c9a3f3ad3fa793456365b1b3ca700c7299099646813b43dcad6249ba77a469f"
     )
コード例 #43
0
 def test_sign_testnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client,
         "Testnet",
         [0],
         "This is an example of a signed message.",
         script_type=proto.InputScriptType.SPENDWITNESS,
     )
     assert sig.address == "tb1qyjjkmdpu7metqt5r36jf872a34syws336p3n3p"
     assert (
         sig.signature.hex()
         == "289e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #44
0
 def test_sign_grs(self):
     self.setup_mnemonic_allallall()
     sig = btc.sign_message(
         self.client,
         "Groestlcoin",
         parse_path("84'/17'/0'/0/0"),
         "test",
         script_type=proto.InputScriptType.SPENDWITNESS,
     )
     assert sig.address == "grs1qw4teyraux2s77nhjdwh9ar8rl9dt7zww8r6lne"
     assert (
         base64.b64encode(sig.signature)
         == b"KIJT20tKHV2sBZKWOFMQo1PvgJksR3ekQTOjNdEtNETabCh9Mq7EBx7EmuMn4gj4m6ChFaEp8QYiHI3VWQ/T3xM="
     )
コード例 #45
0
 def test_sign_long(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client,
         "Bitcoin",
         [0],
         "VeryLongMessage!" * 64,
         script_type=proto.InputScriptType.SPENDP2SHWITNESS,
     )
     assert sig.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
     assert (
         sig.signature.hex()
         == "245ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )
コード例 #46
0
 def test_sign_grs(self):
     self.setup_mnemonic_allallall()
     sig = btc.sign_message(
         self.client,
         "Groestlcoin",
         parse_path("49'/17'/0'/0/0"),
         "test",
         script_type=proto.InputScriptType.SPENDP2SHWITNESS,
     )
     assert sig.address == "31inaRqambLsd9D7Ke4USZmGEVd3PHkh7P"
     assert (
         base64.b64encode(sig.signature)
         == b"I/NA/J+epkaeE9vHQ7cDE+TQdrzYzoZ+3dcexBFg0CpKRiIF0h7G5JUCvz4qhGPUjolcpW9rOFsV7CzHVWKS7K4="
     )
コード例 #47
0
 def test_sign_testnet(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client,
         "Testnet",
         [0],
         "This is an example of a signed message.",
         script_type=proto.InputScriptType.SPENDP2SHWITNESS,
     )
     assert sig.address == "2N4VkePSzKH2sv5YBikLHGvzUYvfPxV6zS9"
     assert (
         sig.signature.hex()
         == "249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #48
0
 def test_sign(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client,
         "Bitcoin",
         [0],
         "This is an example of a signed message.",
         script_type=proto.InputScriptType.SPENDP2SHWITNESS,
     )
     assert sig.address == "3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1"
     assert (
         sig.signature.hex()
         == "249e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80"
     )
コード例 #49
0
 def test_sign_long(self):
     self.setup_mnemonic_nopin_nopassphrase()
     sig = btc.sign_message(
         self.client,
         "Bitcoin",
         [0],
         "VeryLongMessage!" * 64,
         script_type=proto.InputScriptType.SPENDWITNESS,
     )
     assert sig.address == "bc1qyjjkmdpu7metqt5r36jf872a34syws33s82q2j"
     assert (
         sig.signature.hex()
         == "285ff795c29aef7538f8b3bdb2e8add0d0722ad630a140b6aefd504a5a895cbd867cbb00981afc50edd0398211e8d7c304bb8efa461181bc0afa67ea4a720a89ed"
     )