mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 16:48:09 +00:00
tools: add header to ed25519raw.py, fix whitespace in keytool
This commit is contained in:
parent
99915f1a63
commit
f92e8b6e4b
@ -1,3 +1,6 @@
|
|||||||
|
# orignal version downloaded from https://ed25519.cr.yp.to/python/ed25519.py
|
||||||
|
# modified for Python 3 by Jochen Hoenicke <hoenicke@gmail.com>
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
b = 256
|
b = 256
|
||||||
@ -9,9 +12,9 @@ def H(m):
|
|||||||
|
|
||||||
def expmod(b,e,m):
|
def expmod(b,e,m):
|
||||||
if e < 0:
|
if e < 0:
|
||||||
raise Exception('negative exponent')
|
raise Exception("negative exponent")
|
||||||
if e == 0: return 1
|
if e == 0: return 1
|
||||||
t = expmod(b,e >> 1,m)**2 % m
|
t = expmod(b,e>>1,m)**2 % m
|
||||||
if e & 1: t = (t*b) % m
|
if e & 1: t = (t*b) % m
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
@ -233,14 +233,11 @@ def test():
|
|||||||
commits.append(R)
|
commits.append(R)
|
||||||
sigs.append(ed25519raw.encodeint(S))
|
sigs.append(ed25519raw.encodeint(S))
|
||||||
|
|
||||||
|
|
||||||
print('-----------------')
|
print('-----------------')
|
||||||
sig = combine_sig(globalR, [sigs[i] for i in [1,3,4]])
|
sig = combine_sig(globalR, [sigs[i] for i in [1,3,4]])
|
||||||
print('Global sig: %s' %hex(sig))
|
print('Global sig: %s' %hex(sig))
|
||||||
ed25519raw.checkvalid(sig, digest, globalPk)
|
ed25519raw.checkvalid(sig, digest, globalPk)
|
||||||
print('Valid Signature!')
|
print('Valid Signature!')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
Loading…
Reference in New Issue
Block a user