Detailed overview of public/private key encryption and live demo of exactly how digital signatures work on Mac, combining public and private keys and hash functions.

Welcome to episode 3 of my series on Blockchain/Bitcoin. I’m joined once again by my girlfriend Nadisha who is my classroom pupil…

I build on the hash function concepts from the previous episode and explain the basic concepts public and private keys and how to use them to create digital signatures – a key part of the bitcoin infrastructure.

We demonstrate in a Mac terminal how you can generate your own keys and encrypt and decrypt and sign your own resources – learning by doing always works.

We touch on bitcoin addresses, what they represent and how they are created.

Finally I go back for a refresh of the bitcoin blockchain browser and look at the first ever bitcoin transaction in the “Genesis Block” to show what a real bitcoin address looks like.

Bitcoin Blockchain browser

Online hash calculator – great way to practice and familiarise with hash functions – one of the most important building blocks of Blockchain/Bitcoin

Course to date (previous videos)

1. Blockchain introduction

2. Hashing, blockchain networks and look at blockchain browser

SAMPLE COMMANDS: You will need to use your own document – pick any document, obviously your hash values will be different to mine.

Also I had to use (right arrow) – since comments do not allow “chevron” symbols


# generate public and private keys
openssl genrsa -out mykey 2048; cp mykey privatekey; openssl rsa -in mykey -pubout -out publickey; rm mike

#encrypt with public key
echo “the cat sat on the mat” | openssl rsautl -encrypt -pubin -inkey publicly (right arrow) cipher.txt

# show the garbage
cat cipher.txt

# decrypt with private key – The cat sat on the mat
cat cipher.txt | openssl rsautl -decrypt -inkey privately

# EXAMPLE 2: Sign Alice in wonderland

#check the SHA256 hash of the document to send – d9db7b8984d808b2821070cc6cc76e4415229d3356452b2a0f06ec3608f13b6c
shasum -a 256 alice-in-wonderland.txt | cut -d” ” -f1

# create a text file called signature which hashes the document and encrypts with private key
shasum -a 256 alice-in-wonderland.txt | cut -d” ” -f1 | openssl rsautl -inkey privatekey -sign (right arrow) signature

# wrap the signature up with the public key, the document and the signature and send it … we just copy to another folder
tar -cvf alice.tar signature alice-in-wonderland.txt publickey;mkdir -p inbox;cp alice.tar inbox;cd inbox;tar -xvf alice.tar

# inspect the public key and verify with the sender that it belongs to the sender
cat publickey

#decrypt the signature with the received public key – d9db7b8984d808b2821070cc6cc76e4415229d3356452b2a0f06ec3608f13b6c
openssl rsautl -inkey publickey -pubin -in signature

# hash the received document – d9db7b8984d808b2821070cc6cc76e4415229d3356452b2a0f06ec3608f13b6c
shasum -a 256 alice-in-wonderland.txt | cut -d” ” -f1

# if they are both the same then the document cannot have been changed since it was signed by the genuine owner of the
# private key corresponding to the public key

Products You May Like

Articles You May Like

Bitcoin mining vixes site 2020|bonus 3$|crypto world tips
24/7 Live Bitcoin Price and Significant Trades
What’s Hideo Kojima Teasing for Death Stranding in 2020?
Coinbase CEO announces HUGE 5,000+ Bitcoin Crypto Airdrop [LIVE 🔴]

Leave a Reply

Your email address will not be published. Required fields are marked *