1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

revert ckd_public.py removal of bytes/string handling

This commit is contained in:
Pavol Rusnak 2017-12-18 22:40:11 +01:00
parent c1b1bedb8c
commit 094d0b6ffb
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -32,13 +32,20 @@ from . import messages as proto
PRIME_DERIVATION_FLAG = 0x80000000
if sys.version_info < (3,):
def byteindex(data, index):
return ord(data[index])
else:
def byteindex(data, index):
return data[index]
def point_to_pubkey(point):
order = SECP256k1.order
x_str = number_to_string(point.x(), order)
y_str = number_to_string(point.y(), order)
vk = x_str + y_str
return struct.pack('B', vk[63] & 1 + 2) + vk[0:32] # To compressed key
return struct.pack('B', (byteindex(vk, 63) & 1) + 2) + vk[0:32] # To compressed key
def sec_to_public_pair(pubkey):
@ -145,7 +152,7 @@ def deserialize(xpub):
node.chain_code = data[13:45]
key = data[45:-4]
if key[0] == 0:
if byteindex(key, 0) == 0:
node.private_key = key[1:]
else:
node.public_key = key