1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 00:28:10 +00:00

tools: add header to ed25519raw.py, fix whitespace in keytool

This commit is contained in:
Pavol Rusnak 2017-04-02 23:03:07 +02:00
parent 99915f1a63
commit f92e8b6e4b
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 7 additions and 7 deletions

View File

@ -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
b = 256
@ -9,9 +12,9 @@ def H(m):
def expmod(b,e,m):
if e < 0:
raise Exception('negative exponent')
raise Exception("negative exponent")
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
return t

View File

@ -190,7 +190,7 @@ def test():
data = sys.argv[1].encode('utf-8')
N = 5
keyset = [1,3,4]
digest = pyblake2.blake2s(data).digest()
print('Digest: %s' % hex(digest))
sks = []
@ -212,7 +212,7 @@ def test():
print('Local commit: %s' % hex(R))
nonces.append(r)
commits.append(R)
globalPk = combine_keys([pks[i] for i in keyset])
globalR = combine_keys([commits[i] for i in keyset])
print('-----------------')
@ -232,15 +232,12 @@ def test():
print('Local sig %d: %s' % (i+1, hex(ed25519raw.encodeint(S))))
commits.append(R)
sigs.append(ed25519raw.encodeint(S))
print('-----------------')
sig = combine_sig(globalR, [sigs[i] for i in [1,3,4]])
print('Global sig: %s' %hex(sig))
ed25519raw.checkvalid(sig, digest, globalPk)
print('Valid Signature!')
if __name__ == '__main__':
test()