openmedialibrary/oml/ed25519_utils.py
2014-05-12 04:09:31 +02:00

14 lines
335 B
Python

import ed25519
ENCODING='base64'
def valid(key, value, sig):
'''
validate that value was signed by key
'''
vk = ed25519.VerifyingKey(str(key), encoding=ENCODING)
try:
vk.verify(str(sig), str(value), encoding=ENCODING)
#except ed25519.BadSignatureError:
except:
return False
return True