diff --git a/tools/ed25519raw.py b/tools/ed25519raw.py index c7ad69eb85..4d16d548b0 100644 --- a/tools/ed25519raw.py +++ b/tools/ed25519raw.py @@ -1,3 +1,6 @@ +# orignal version downloaded from https://ed25519.cr.yp.to/python/ed25519.py +# modified for Python 3 by Jochen Hoenicke + 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 diff --git a/tools/keytool b/tools/keytool index ebe68431fe..7eff01c3e2 100755 --- a/tools/keytool +++ b/tools/keytool @@ -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()