mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-15 18:00:59 +00:00
ed25519: remove py2/py3 handling in ed25519 funcs as well
This commit is contained in:
parent
a9291e89c5
commit
c1b1bedb8c
@ -21,10 +21,7 @@ def combine_sig(R, sigs):
|
||||
def get_nonce(sk, data, ctr):
|
||||
h = ed25519raw.H(sk)
|
||||
b = ed25519raw.b
|
||||
if sys.version_info.major < 3:
|
||||
r = ed25519raw.Hint(''.join([h[i] for i in range(b >> 3, b >> 2)]) + data + binascii.unhexlify('%08x' % ctr))
|
||||
else:
|
||||
r = ed25519raw.Hint(bytes([h[i] for i in range(b >> 3, b >> 2)]) + data + binascii.unhexlify('%08x' % ctr))
|
||||
r = ed25519raw.Hint(bytes([h[i] for i in range(b >> 3, b >> 2)]) + data + binascii.unhexlify('%08x' % ctr))
|
||||
R = ed25519raw.scalarmult(ed25519raw.B, r)
|
||||
return r, ed25519raw.encodepoint(R)
|
||||
|
||||
|
@ -69,27 +69,18 @@ def scalarmult(P, e):
|
||||
|
||||
def encodeint(y):
|
||||
bits = [(y >> i) & 1 for i in range(b)]
|
||||
if sys.version_info.major < 3:
|
||||
return ''.join([chr(sum([bits[i * 8 + j] << j for j in range(8)])) for i in range(b >> 3)])
|
||||
else:
|
||||
return bytes([sum([bits[i * 8 + j] << j for j in range(8)]) for i in range(b >> 3)])
|
||||
return bytes([sum([bits[i * 8 + j] << j for j in range(8)]) for i in range(b >> 3)])
|
||||
|
||||
|
||||
def encodepoint(P):
|
||||
x = P[0]
|
||||
y = P[1]
|
||||
bits = [(y >> i) & 1 for i in range(b - 1)] + [x & 1]
|
||||
if sys.version_info.major < 3:
|
||||
return ''.join([chr(sum([bits[i * 8 + j] << j for j in range(8)])) for i in range(b >> 3)])
|
||||
else:
|
||||
return bytes([sum([bits[i * 8 + j] << j for j in range(8)]) for i in range(b >> 3)])
|
||||
return bytes([sum([bits[i * 8 + j] << j for j in range(8)]) for i in range(b >> 3)])
|
||||
|
||||
|
||||
def bit(h, i):
|
||||
if sys.version_info.major < 3:
|
||||
return (ord(h[i >> 3]) >> (i & 7)) & 1
|
||||
else:
|
||||
return (h[i >> 3] >> (i & 7)) & 1
|
||||
return (h[i >> 3] >> (i & 7)) & 1
|
||||
|
||||
|
||||
def publickey(sk):
|
||||
|
Loading…
Reference in New Issue
Block a user