예제 #1
0
    async def _int_test_trezor_txs(self, as_bulletproof=False, client_version=1, hf=10):
        if os.getenv('SKIP_TREZOR_TSX', False):
            self.skipTest('Skipped by ENV var')

        files = self.get_trezor_tsx_tests()
        creds = self.get_trezor_creds(0)
        all_creds = self.get_all_trezor_creds()

        if not os.getenv('FORCE_ALL_TESTS', False) and not crypto.get_backend().is_fast():
            files = files[0:3]

        for fl in files:
            with self.subTest(msg=fl):
                unsigned_tx_c = self.get_data_file(fl)
                unsigned_tx = await wallet.load_unsigned_tx(
                    creds.view_key_private, unsigned_tx_c
                )

                for tx in unsigned_tx.txes:
                    if as_bulletproof:
                        tx.use_rct = False
                        tx.use_bulletproofs = True

                tagent = self.init_agent(creds=creds)
                tagent.client_version = client_version
                tagent.hf = hf
                await self.tx_sign_test(tagent, unsigned_tx, creds, all_creds, fl)
예제 #2
0
def prove_range(
    amount,
    last_mask=None,
    use_asnl=False,
    mem_opt=True,
    backend_impl=False,
    decode=False,
    byte_enc=False,
    rsig=None,
):
    """
    Range proof generator.
    In order to minimize the memory consumption and CPU usage during transaction generation the returned values
    are returned encoded.

    :param amount:
    :param last_mask:
    :param use_asnl: ASNL range proof, insecure
    :param mem_opt: memory optimized
    :param backend_impl: backend implementation, if available
    :param decode: decodes output
    :param byte_enc: decodes output
    :param rsig: buffer for rsig
    :return:
    """
    if use_asnl and mem_opt:
        raise ValueError("ASNL not in memory optimized variant")
    if backend_impl and use_asnl:
        raise ValueError("ASNL not supported in backend")

    if backend_impl and crypto.get_backend().has_rangeproof_borromean():
        if byte_enc and decode:
            raise ValueError("Conflicting options byte_enc, decode")

        C, a, R = crypto.prove_range(amount,
                                     last_mask)[:3]  # backend returns encoded
        if not byte_enc:
            R = monero.inflate_rsig(R)
        if decode:
            R = monero.inflate_rsig(R)
            R = monero.recode_rangesig(R, encode=False)

        return C, a, R

    ret = None
    if use_asnl and not mem_opt:
        ret = prove_range_orig(amount, last_mask=last_mask, use_asnl=True)
    else:
        ret = prove_range_mem(amount, last_mask=last_mask)

    # Encoding
    C, a, R = ret[:3]
    if byte_enc:
        R = monero.recode_rangesig(R, encode=True)
        R = monero.flatten_rsig(R)
    elif not decode:
        R = monero.recode_rangesig(R, encode=True)

    return C, a, R
예제 #3
0
 async def test_trezor_txs_bp_c1_hf10(self):
     if not crypto.get_backend().has_rangeproof_bulletproof():
         self.skipTest('Crypto backend does not support BPs')
     await self._int_test_trezor_txs(as_bulletproof=True, client_version=1, hf=10)
예제 #4
0
 def can_test(self):
     return crypto.get_backend().has_crypto_into_functions()
예제 #5
0
 async def test_trezor_txs_bp(self):
     if not crypto.get_backend().has_rangeproof_bulletproof():
         self.skipTest('Crypto backend does not support BPs')
     await self._int_test_trezor_txs(as_bulletproof=True)