Practical Cryptography for Developers: Hashes, MAC, Key Derivation, DHKE, Symmetric and Asymmetric Ciphers, Public Key Cryptosystems, RSA, Elliptic Curves, ECC, secp256k1, ECDH, ECIES, Digital Signatures, ECDSA, EdDSA
3.42k
stars
409
forks
source link
ImportError: cannot import name 'sign', 'verify' #58
Open
MilanObrenovic opened 1 year ago
from pycoin.ecdsa import generator_secp256k1, sign, verify import hashlib, secrets
def sha3_256Hash(msg): hashBytes = hashlib.sha3_256(msg.encode("utf8")).digest() return int.from_bytes(hashBytes, byteorder="big")
def signECDSAsecp256k1(msg, privKey): msgHash = sha3_256Hash(msg) signature = sign(generator_secp256k1, privKey, msgHash) return signature
def verifyECDSAsecp256k1(msg, signature, pubKey): msgHash = sha3_256Hash(msg) valid = verify(generator_secp256k1, pubKey, msgHash, signature) return valid
i think the example code is broken or outdated. i cant import sign or verify at all