concept public key in category cryptography

appears as: public key, public key, public keys, public keys
Real-World Cryptography MEAP V09

This is an excerpt from Manning's book Real-World Cryptography MEAP V09.

Once they have done that, they both individually combine their secret shape with the common shape they initially agreed on using. This gives out a unique shape, which represents their public key (see figure 1.9).

Figure 1.9. The second step of a Diffie-Hellman key exchange is to have both participants exchange their public keys. Participants derive their public keys by combining their private keys with the common shape.
blending

We are now starting to see why this algorithm is called a public-key algorithm. It is because it requires a key pair: a private key and a public key.

One solution is asymmetric encryption! With such a primitive, anyone can encrypt messages to you using your public key, and you are the only one who can decrypt such messages via your associated private key. See figure 6.1.

Figure 6.1. With asymmetric encryption, anyone can use Alice’s public key to send her encrypted messages. Only Alice, who owns the associated private key, can decrypt these messages.
example

Now assuming that you know for sure that the public key you’re using is Alice’s, the protocol is still not mutually authenticating the participants. Only you know you are encrypting to Alice, but Alice still has no way to verify your identity.

Listing 7.1. signature.py contains code to sign and verify signatures
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey #1

private_key = Ed25519PrivateKey.generate() #2
public_key = private_key.public_key() #2

message = b"example.com has the public key 0xab70..." #3
signature = private_key.sign(message) #3

try: #4
    public_key.verify(signature, message) #4
    print("valid signature") #4
catch InvalidSignature: #4
    print("invalid signature") #4
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest