Skip to Content
Foundations of Blockchain
book

Foundations of Blockchain

by Koshik Raj
January 2019
Beginner to intermediate
372 pages
11h 17m
English
Packt Publishing
Content preview from Foundations of Blockchain

ECDSA example to create and verify a digital signature

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Basics

Blockchain Basics

Daniel Drescher
What Is Blockchain?

What Is Blockchain?

Sir John Hargrave, Evan Karnoupakis
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey

Publisher Resources

ISBN: 9781789139396Supplemental Content