示例#1
0
    async def live_refresh(self, view_key_private, out_key, recv_deriv,
                           real_out_idx, major, minor):
        msg = MoneroLiveRefreshStepRequest(
            out_key=out_key,
            recv_deriv=recv_deriv,
            real_out_idx=real_out_idx,
            sub_addr_major=major,
            sub_addr_minor=minor,
        )
        t_res = await self.trezor.live_refresh(
            msg)  # type: MoneroLiveRefreshStepAck
        self.handle_error(t_res)

        enc_key = self._compute_ki_enc_key_host(view_key_private, out_key,
                                                t_res.salt)
        decr = chacha_poly.decrypt_pack(enc_key, t_res.key_image)

        ki_bin = decr[:32]
        ki = crypto.decodepoint(ki_bin)
        sig = [[crypto.decodeint(decr[32:64]), crypto.decodeint(decr[64:])]]

        if not ring_ct.check_ring_singature(
                ki_bin, ki, [crypto.decodepoint(out_key)], sig):
            raise ValueError("Invalid ring sig on KI")

        return ki
示例#2
0
 async def verify_ki_export(self, res, exp):
     """
     Verifies key image export
     :param res:
     :param exp:
     :return:
     """
     self.assertTrue(len(res) > 0)
     for idx, kie in enumerate(res):
         td = exp.tds[idx]
         ki = crypto.decodepoint(kie[0])
         pkey = crypto.decodepoint(td.m_tx.vout[td.m_internal_output_index].target.key)
         sig = [[crypto.decodeint(kie[1][0]), crypto.decodeint(kie[1][1])]]
         self.assertTrue(ring_ct.check_ring_singature(kie[0], ki, [pkey], sig))
示例#3
0
    def test_key_image_signature(self):
        ki = binascii.unhexlify(
            b"a248206cea806a7d60ea936cdc35efdf44a189b1026c4e658f42216aec155383"
        )
        c0 = binascii.unhexlify(
            b"032725822d2c0f37bb67f29e116dc8c64ec02c4e8c69b147f596e7dbbc899409"
        )
        r0 = binascii.unhexlify(
            b"2e4839b81c74f5b17d842d5f15723813b5287cfbc44539c9154d9222b65d2b07"
        )
        pub = binascii.unhexlify(
            b"346354ca120bf3210976b1f5a9cee897628f3745fb80d5525c22f8cffd78a5c7"
        )

        self.assertEqual(
            1,
            ring_ct.check_ring_singature(
                ki,
                crypto.decodepoint(ki),
                [crypto.decodepoint(pub)],
                [[crypto.decodeint(c0), crypto.decodeint(r0)]],
            ),
        )