Esempio n. 1
0
    def test_vsys_sign_tx_proposal(self, client):
        with client:
            client.set_input_flow(self.input_flow(client.debug, num_pages=1))
            public_key = vsys.get_public_key(client, VSYS_PATH)
            resp = vsys.sign_tx(
                client,
                VSYS_PATH,
                dict_to_proto(
                    messages.VsysSignTx,
                    {
                        "protocol": "v.systems",
                        "api": 1,
                        "opc": "transaction",
                        "transactionType": 2,
                        "senderPublicKey": public_key,
                        "amount": 1000000000,
                        "fee": 10000000,
                        "feeScale": 100,
                        "recipient": "AU6GsBinGPqW8zUuvmjgwpBNLfyyTU3p83Q",
                        "timestamp": 1547722056762119200,
                        "attachment": "HXRC"
                    },
                ),
            )

        context_bytes = [
            0x02, 0x15, 0x7a, 0x9d, 0x02, 0xac, 0x57, 0xd4, 0x20, 0x00, 0x00,
            0x00, 0x00, 0x3b, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x98, 0x96, 0x80, 0x00, 0x64, 0x05, 0x54, 0x9c, 0x6d, 0xf7, 0xb3,
            0x76, 0x77, 0x1b, 0x19, 0xff, 0x3b, 0xdb, 0x58, 0xd0, 0x4b, 0x49,
            0x99, 0x91, 0x66, 0x3c, 0x47, 0x44, 0x4e, 0x42, 0x5f, 0x00, 0x03,
            0x31, 0x32, 0x33
        ]

        assert (curve.verifySignature(b58decode(public_key),
                                      bytes(context_bytes),
                                      b58decode(resp.signature)) == 0)
Esempio n. 2
0
def deserialize(xpub):
    data = tools.b58decode(xpub, None)

    if tools.btc_hash(data[:-4])[:4] != data[-4:]:
        raise ValueError("Checksum failed")

    node = messages.HDNodeType()
    node.depth = struct.unpack(">B", data[4:5])[0]
    node.fingerprint = struct.unpack(">I", data[5:9])[0]
    node.child_num = struct.unpack(">I", data[9:13])[0]
    node.chain_code = data[13:45]

    key = data[45:-4]
    if key[0] == 0:
        node.private_key = key[1:]
    else:
        node.public_key = key

    return node
Esempio n. 3
0
def deserialize(xpub):
    data = tools.b58decode(xpub, None)

    if tools.btc_hash(data[:-4])[:4] != data[-4:]:
        raise ValueError("Checksum failed")

    node = messages.HDNodeType()
    node.depth = struct.unpack(">B", data[4:5])[0]
    node.fingerprint = struct.unpack(">I", data[5:9])[0]
    node.child_num = struct.unpack(">I", data[9:13])[0]
    node.chain_code = data[13:45]

    key = data[45:-4]
    if key[0] == 0:
        node.private_key = key[1:]
    else:
        node.public_key = key

    return node