January 2019
Beginner to intermediate
372 pages
11h 17m
English
The following packages are used to perform hashing, ECC key creation, and signature creation and verification:
from Crypto.Hash import SHA256 from Crypto.PublicKey import ECC from Crypto.Signature import DSS
The key is generated on the secp256k1 elliptical curve using the ECC.generate method, and both public and private keys are exported:
key = ECC.generate(curve='P-256')
with open('ecc.pub', 'wt') as f:
f.write(key.public_key().export_key(format='PEM'))
with open('ecc.pem', 'wt') as f:
f.write(key.export_key(format='PEM'))
Messages that need to be signed are hashed using the SHA256 algorithm, and then a signer object is created using the DSS package by providing a private key. The ...