From 5ccb2fbbac4d9aeddb5064d7de620644536714e7 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Wed, 12 Sep 2018 17:05:27 +0200 Subject: [PATCH] xmr: wrappers cleanup --- src/apps/monero/xmr/common.py | 58 ---------------------------------- src/apps/monero/xmr/ring_ct.py | 4 +-- 2 files changed, 2 insertions(+), 60 deletions(-) diff --git a/src/apps/monero/xmr/common.py b/src/apps/monero/xmr/common.py index 124e6b4fe..b86aea83b 100644 --- a/src/apps/monero/xmr/common.py +++ b/src/apps/monero/xmr/common.py @@ -5,37 +5,11 @@ class XmrException(Exception): pass -def random_bytes(by): - """ - Generates X random bytes, returns byte-string - :param by: - :return: - """ - return random.bytes(by) - - def ct_equal(a, b): - """ - Constant time a,b comparison - :param a: - :param b: - :return: - """ return monero.ct_equals(a, b) -def memcpy(dst, dst_from, src, src_from, length): - from trezor.utils import memcpy - - return memcpy(dst, dst_from, src, src_from, length) - - def check_permutation(permutation): - """ - Check permutation sanity - :param permutation: - :return: - """ for n in range(len(permutation)): if n not in permutation: raise ValueError("Invalid permutation") @@ -62,41 +36,9 @@ def apply_permutation(permutation, swapper): def is_empty(inp): - """ - True if none or empty - :param inp: - :return: - """ return inp is None or len(inp) == 0 -def defval(val, default=None): - """ - Returns val if is not None, default instead - :param val: - :param default: - :return: - """ - return val if val is not None else default - - def defval_empty(val, default=None): - """ - Returns val if is not None, default instead - :param val: - :param default: - :return: - """ return val if not is_empty(val) else default - -def chunk(arr, size=1): - res = [] - idx = 0 - while True: - c = arr[idx : idx + size] - res.append(c) - idx += size - if len(c) != size: - break - return res diff --git a/src/apps/monero/xmr/ring_ct.py b/src/apps/monero/xmr/ring_ct.py index 2769e63ef..d81179354 100644 --- a/src/apps/monero/xmr/ring_ct.py +++ b/src/apps/monero/xmr/ring_ct.py @@ -178,7 +178,7 @@ def generate_ring_signature(prefix_hash, image, pubs, sec, sec_idx, test=False): :param test: :return: """ - from apps.monero.xmr.common import memcpy + from trezor.utils import memcpy if test: from apps.monero.xmr import monero @@ -250,7 +250,7 @@ def check_ring_singature(prefix_hash, image, pubs, sig): :param sig: :return: """ - from apps.monero.xmr.common import memcpy + from trezor.utils import memcpy image_unp = crypto.ge_frombytes_vartime(image) image_pre = crypto.ge_dsm_precomp(image_unp)