Move decompression into device.pubkey()

This commit is contained in:
Roman Zeyde
2020-09-24 13:51:00 +03:00
parent d0e7fa7cca
commit a12202d809
5 changed files with 15 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ import struct
from ledgerblue import comm # pylint: disable=import-error
from . import interface
from .. import formats
log = logging.getLogger(__name__)
@@ -64,7 +65,9 @@ class LedgerNanoS(interface.Device):
log.debug('apdu: %r', apdu)
result = bytearray(self.conn.exchange(bytes(apdu)))
log.debug('result: %r', result)
return _convert_public_key(curve_name, result[1:])
return formats.decompress_pubkey(
pubkey=_convert_public_key(curve_name, result[1:]),
curve_name=identity.curve_name)
def sign(self, identity, blob):
"""Sign given blob and return the signature (as bytes)."""

View File

@@ -6,6 +6,7 @@ import logging
import semver
from . import interface
from .. import formats
log = logging.getLogger(__name__)
@@ -87,7 +88,8 @@ class Trezor(interface.Device):
n=addr,
ecdsa_curve_name=curve_name)
log.debug('result: %s', result)
return bytes(result.node.public_key)
pubkey = bytes(result.node.public_key)
return formats.decompress_pubkey(pubkey=pubkey, curve_name=identity.curve_name)
def _identity_proto(self, identity):
result = self._defs.IdentityType()