LoginSignup
0
0

More than 5 years have passed since last update.

Python:eccでJose alg=ES512

Last updated at Posted at 2014-03-07

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'))

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0