Closed NotStatilko closed 4 years ago
Just tested under sha256
with True
as result. secp256k1
can only be in pair with Bitcoin's hash function?
Hey there, the privkey
is just an integer, it doesn't have any information about the curve embedded in it. So the sign
method needs to have the curve being used passed to it (docs). Note the parameter fastecdsa.curve.Curve = P256
in the signature in the docs, the default curve is P256. This should work -
from fastecdsa import keys, curve as curve_, ecdsa
from hashlib import sha3_256
curve = curve_.secp256k1
message = b'Hello, World!'
privkey, pubkey = keys.gen_keypair(curve=curve)
sign = ecdsa.sign(message, privkey, curve=curve, hashfunc=sha3_256)
print(ecdsa.verify(sign, message, pubkey,
hashfunc=sha3_256, curve=curve)
)
Oh, thank you! Now it works.
Hello! I recently installed your library via
pip
and tried to sign and verify message withsecp256k1
. As a result i haveFalse
, although to me the code seems correct. Can you help me with this?Also, when i replace
curve
withcurve_.P256
i getTrue
. Is it a bug?