Edited at

Python:eccでJose alg=ES512

More than 5 years have passed since last update.

python-edcsa より簡単な気が。

インストール:

$ pip install ecc

Jose alg=ES512 (ECDSA using P-521 curve and SHA-512):

    class TestEcKeyEcc(unittest.TestCase):

def test_generate(self):
from ecc.Key import Key

pri = Key.generate(521)
self.assertTrue(isinstance(pri, Key))
self.assertTrue(pri.private())

pub = Key.decode(pri.encode())
self.assertTrue(isinstance(pub, Key))
self.assertFalse(pub.private())

msg = "hello, it's me."
sig = pri.sign(msg, hashfunc='sha512') # default sha256
self.assertTrue(pub.verify(msg, sig, hashfunc='sha512'))