diff --git a/src/apps/monero/xmr/bulletproof.py b/src/apps/monero/xmr/bulletproof.py index 840cfea8a..1a08e2fea 100644 --- a/src/apps/monero/xmr/bulletproof.py +++ b/src/apps/monero/xmr/bulletproof.py @@ -274,6 +274,7 @@ class KeyV(object): def __init__(self, elems=64, src=None, buffer=None): self.current_idx = 0 self.d = None + self.mv = None self.size = elems if src: self.d = bytearray(src.d) @@ -283,6 +284,10 @@ def __init__(self, elems=64, src=None, buffer=None): self.size = len(buffer) // 32 else: self.d = bytearray(32 * elems) + self._set_mv() + + def _set_mv(self): + self.mv = memoryview(self.d) def __getitem__(self, item): """ @@ -290,7 +295,7 @@ def __getitem__(self, item): :param item: :return: """ - return memoryview(self.d)[item * 32 : (item + 1) * 32] + return self.mv[item * 32 : (item + 1) * 32] def __setitem__(self, key, value): """ @@ -326,10 +331,14 @@ def slice_r(self, start, stop): res = KeyV(stop - start) return self.slice(res, start, stop) + def copy_from(self, src): + self.size = self.size + self.d = bytearray(self.d) + self._set_mv() + def copy(self, dst=None): if dst: - dst.size = self.size - dst.d = bytearray(self.d) + dst.copy_from(self) else: dst = KeyV(src=self) return dst @@ -342,6 +351,7 @@ def resize(self, nsize, chop=False): else: self.d = bytearray(nsize * 32) self.size = nsize + self._set_mv() class KeyVEval(KeyV):