< Return to Cryptocurrencies

Crypto Transactions: Public and Private Keys

Education Hero Image

Public and Private Keys: The Building Blocks of Secret Codes

Key Pairs: Public and Private Keys

A public key is a special code that everyone can know. It's like having a lock that many people can use, but only in one direction. This key helps to lock up information so that only the right person can open it later.

Example: In one type of secret code called RSA, the public key has a big number (modulus) and a special smaller number (exponent). These numbers work together to lock up messages.

A private key is a secret code that only one person knows. It's like having a key to a special lock that only you can open. This key is used to unlock the messages that were locked with the public key.

Example: In RSA, the private key also has a big number (modulus) and another special number (private exponent). These numbers work together to unlock the messages.

Key Generation

Public and private keys are made using special math. Let's see how they are created:

Prime Number Selection: Special math picks two big secret numbers, called prime numbers.

Key Calculation: More special math calculates two things: a big number (modulus) and another number using the prime numbers.

Public Key Derivation: Another special math picks a number that works with the calculated numbers. This becomes the public key.

Private Key Calculation: Even more special math calculates another number. This becomes the private key.

Encryption and Decryption

Encryption: Encrypting a message means making it secret. With the public key, a sender can lock up a message so only the person with the private key can open it.

Example: In RSA, a sender uses the receiver's public key to lock up a message.

Decryption: Decrypting a message means opening the locked message. The person with the private key can use it to unlock and read the message.

Example: In RSA, the receiver uses their private key to unlock and read the message.

Digital Signatures

Signature Creation: Creating a digital signature means making a special code that shows a message is real. The person uses their private key to make this code.

Example: In another secret code called ECDSA, the signer uses their private key to make a signature for a message.

Signature Verification: Verifying a signature means checking if the special code is real. The person uses the public key and the original message to check if the code matches.

Example: In ECDSA, the receiver checks the signature using the signer's public key.

Address Generation

Cryptocurrency addresses, like where you get mail, come from public keys. They help to make sure only the right person gets the money.

Example: Bitcoin addresses are made by doing some special math with the public key.

Conclusion

Public and private keys are like secret codes that keep our online activities safe. They work together to lock and unlock messages, create digital signatures, and make sure the right person gets the money in cryptocurrency. Understanding how these keys work helps keep our information secure when we use the internet.

This article takes inspiration from a lesson found in 15.S12 at MIT.