Closed SolarisYan closed 8 years ago
If you are using v1.1.2 (i.e. if you installed via pip
) or before the keys
module does not exist yet. It is only available in the current "dev" version. A quick $ pip show fastecdsa
should indicate the version. The old version uses fastecdsa.ecdsa.gen_keypair()
. Usage for the older versions can be found in the accompanying README, or see the example below:
from fastecdsa import curve, ecdsa
from hashlib import sha384
m = "a message to sign via ECDSA" # some message
''' use default curve and hash function (P256 and SHA2) '''
private_key, public_key = ecdsa.gen_keypair()
# standard signature, returns two integers
r, s = ecdsa.sign(m, private_key)
# should return True as the signature we just generated is valid.
valid = ecdsa.verify((r, s), m, public_key)
''' specify a different curve to use with ECDSA '''
private_key, public_key = ecdsa.gen_keypair(curve=curve.P224)
r, s = ecdsa.sign(m, private_key, curve=curve.P224)
valid = ecdsa.verify((r, s), m, public_key, curve=curve.P224)
''' specify a different hash function to use with ECDSA '''
private_key, public_key = ecdsa.gen_keypair()
r, s = ecdsa.sign(m, private_key, hashfunc=sha384)
valid = ecdsa.verify((r, s), m, public_key, hashfunc=sha384)
Hope that helps -Anton
do you plan to add the function: keys ?
If you clone this repo and do $ pip install -e .
inside it you'll have the newest version with the keys
module. There no plans for a "keys" function.
The package is now at version 1.1.3 which includes the keys
module.
Fixed in 8c2a545.
hello, when i do this: from fastecdsa import keys, curve
it return an error like
ImportError: cannot import name keys
So how ?