Created
March 19, 2019 15:12
-
-
Save JacobEberhardt/832144511b607225959232e72ab25a8f to your computer and use it in GitHub Desktop.
Python example of EdDSA signature generation to be used with ZoKrates EdDSA verification.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
from zokrates.eddsa import PrivateKey, PublicKey | |
from zokrates.field import FQ | |
from zokrates.utils import write_for_zokrates_cli | |
if __name__ == "__main__": | |
raw_msg = "This is my secret message" | |
msg = hashlib.sha512(raw_msg.encode("utf-8")).digest() | |
# sk = PrivateKey.from_rand() | |
# Seeded for debug purpose | |
key = FQ(1997011358982923168928344992199991480689546837621580239342656433234255379025) | |
sk = PrivateKey(key) | |
sig = sk.sign(msg) | |
pk = PublicKey.from_private(sk) | |
is_verified = pk.verify(sig, msg) | |
print(is_verified) | |
path = './zokrates_args' | |
write_for_zokrates_cli(pk, sig, msg, path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment