π Master your Security+ skills with Pluralsight here: Pluralsight
Youβll learn the difference between public and private keys, which key to share or protect, and how asymmetric encryption and digital signatures work. Build your CompTIA Security+ foundation with clear explanations of PKI and TLS so you can understand how secure connections protect data and verify identities.
Chapters: 0:00 Intro 0:13 What's the difference between a public key and a private key? 0:51 Which key encrypts and which key decrypts? 1:33 How do private keys create digital signatures? 2:18 How does PKI prove whose public key you're using? 3:17 How do these keys protect everyday connections? 4:16 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Key Takeaways
Share the public key; protect the private key. They form a mathematically related pair, but each algorithm determines whether the keys support encryption, signatures, or key agreement.
Encrypt for the recipient: use their public encryption key; their matching private key enables recovery. Encryption alone does not prove who sent the message.
Sign with the signerβs private key; verify with their public key. Signatures provide integrity and authenticity evidence, not confidentiality, and require trusting that the public key belongs to the claimed signer.
Public keys need authenticity, not secrecy. PKI certificates bind keys to identities, but certificate chains, validity, intended usage, and website names must still be checked.
Modern HTTPS combines asymmetric and symmetric cryptography. In typical certificate-authenticated TLS 1.3, signatures authenticate the server, ephemeral key exchange establishes secrets, and symmetric encryption protects traffic.
Protect private-key storage and control its use. Restrict access, encrypt key files, consider hardware protection, and plan recovery and revocation. Replacing a compromised key cannot undo data already exposed.
π Turn concepts into hands-on skills with Pluralsight, an optional next step offering guided security labs, feedback, assessments, and certification practice to identify knowledge gaps.
The difference between a public key vs private key comes down to what you can share and what you must protect: a public key can be distributed to others, while its matching private key must remain secret and under authorized control.
Together, they enable systems to protect confidential information, verify digital signatures, and establish secure connections. Understanding their different roles helps explain everyday technologies such as HTTPS, SSH authentication, and encrypted messaging.
Public Key vs Private Key: The Core Difference
Public and private keys are mathematically related parts of an asymmetric key pair. With secure algorithms, appropriate settings, and correct implementation, deriving the private key from the public key is computationally impractical.
That is why sharing a public key is not like publishing a password.
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this video.
Feature
Public key
Private key
Must remain secret
No
Yes
Who can receive it
Anyone who needs to communicate with or verify the owner
Only authorized holders or systems
Role in public-key encryption
Encrypts information or protects keying material for the recipient
Decrypts the corresponding protected information
Role in digital signatures
Verifies signatures
Creates signatures
Role in key agreement
Public contribution exchanged with another participant
Secret contribution used locally
These roles describe different cryptographic schemes, not capabilities that every key pair automatically has. A particular algorithm or key may support encryption, signatures, or key agreement, not necessarily all three.
Suppose Alice wants to send confidential information to Bob. The important question is not simply βWhich key encrypts?β but βWhose key should Alice use?β
The answer is the recipientβs:
Alice obtains an authentic copy of Bobβs public encryption key.
Her software encrypts the information, or protects its encryption key, for Bob.
Bob uses his matching private key to recover it.
A useful memory aid is: encrypt for the recipient.
The Open-Padlock Analogy
Imagine Bob distributes open padlocks but keeps the only matching unlocking key.
Anyone can place a message inside a box and close one of Bobβs padlocks. Once the box is locked, only someone with Bobβs unlocking key can open it.
The public key acts like the open padlock; the private key acts like the unlocking key.
This analogy explains confidentiality, but it does not explain digital signatures or key agreement. Those are separate operations.
Encryption Does Not Identify the Sender
Because Bobβs public key is available to others, many people can encrypt messages for him.
Successfully decrypting a message therefore does not, by itself, prove that Alice sent it. Encryption protects confidentiality; verifying the sender requires an additional mechanism, such as a digital signature.
Asymmetric vs Symmetric Encryption
A private key is not the same thing as a symmetric key.
Asymmetric cryptography uses related public and private keys.
Symmetric encryption is efficient for protecting large amounts of data. Its practical challenge is getting the necessary secret to the right participants securely.
Public-key cryptography helps solve that problem. It can protect or establish shared secret material without requiring the participants to already possess the same secret.
Real systems often combine both approaches in hybrid encryption:
Encrypt the content using a symmetric session key.
Use public-key cryptography to protect or establish the secret needed to recover that content.
For example, OpenPGP can encrypt a message symmetrically and protect its session key for the intended recipient. The entire message does not need to be encrypted directly with a public-key encryption algorithm.
How Digital Signatures Use Public and Private Keys
Digital signatures use the key pair differently from encryption.
If Alice wants Bob to verify a document:
Alice creates a signature using her private signing key.
She sends the document and signature.
Bob verifies the signature using Aliceβs public verification key.
The key roles are:
Sign with the signerβs private key. Verify with the signerβs public key.
A valid signature provides evidence that the signed data has not changed and that the corresponding private key generated the signature.
However, identifying the signer as Alice also requires confidence that the verification key really belongs to Alice.
Signing Does Not Hide the Message
A signed document can remain completely readable. The signature provides verification evidence, not confidentiality.
To protect both confidentiality and authenticity, a system may combine encryption and signatures.
It is also misleading to describe signing as βencrypting with the private key.β Encryption schemes and signature schemes are distinct cryptographic constructions, even when they use related mathematics.
Goal
Operation
Key relationship
Keep information confidential for Bob
Encryption
Bobβs public key protects it; Bobβs private key recovers it
Verify Aliceβs signature
Signing and verification
Aliceβs private key signs; Aliceβs public key verifies
How Key Agreement Establishes a Shared Secret
Public/private key pairs can also support key agreement.
In a DiffieβHellman-style exchange, each participant has a private contribution and a corresponding public contribution. They exchange the public contributions, then combine their own private contribution with the other participantβs public contribution.
Both sides derive shared secret material without simply transmitting that secret across the network.
However, key agreement needs authentication. Otherwise, an attacker could substitute their own public contributions and establish separate secrets with each participant.
This distinction matters: establishing a secret and proving whom you established it with are different security tasks.
How PKI Connects Public Keys to Identities
A public key does not need secrecy, but it does need authenticity.
Suppose an attacker gives Alice a public key labeled βBob.β If Alice trusts the label without checking, she could encrypt information for the attacker instead of Bob.
Public key infrastructure, or PKI, addresses this identity-to-key problem through certificates and trust relationships.
Certificates and Certificate Authorities
A public-key certificate contains a public key and associated identifying information. A certificate authority, or CA, digitally signs the certificate to assert that association.
A public-key certificate does not contain the corresponding private key.
When validating a website certificate, a browser checks matters such as the trusted certificate chain, validity period, intended usage, and matching website name.
Simply receiving a certificate is not enough. The certificate must pass the relevant trust checks.
How Public and Private Keys Work in HTTPS
HTTPS uses Transport Layer Security, or TLS, to authenticate connections and protect data in transit.
In a typical certificate-authenticated TLS 1.3 connection:
The server presents its certificate. The browser evaluates the certificate and its connection to a trusted authority.
The server proves possession of its private key. It signs handshake information.
A separate ephemeral key exchange establishes shared secrets.
This is more accurate than saying, βThe browser encrypts the whole website with the serverβs public key.β
The long-term certificate key supports authentication, while separate key-exchange material helps establish the traffic secrets. TLS also supports pre-shared-key modes, so not every connection follows an identical certificate-based process.
The same basic distinction appears across many security technologies:
SSH authentication: A client signs authentication data with its private key. The server verifies the signature using an authorized public key. The private key is not sent to the server.
Passkeys: A service verifies authentication signatures using a stored public key. A local PIN or biometric may authorize private-key use; it is not the private key itself.
Software updates: A publisher signs a release, and receiving systems verify the signature. A valid signature does not prove that software is harmless or bug-free.
Across these examples, knowing a public key is not enough to impersonate its owner. The attacker would need to perform the required operation using the corresponding private key or gain unauthorized access to a system that can use it.
Protecting Private Keys and Handling Compromise
Private-key protection involves both safeguarding stored key material and controlling who can use it.
Appropriate measures can include:
Restricting access to authorized users and services.
Encrypting stored private-key files.
Using hardware protection where appropriate.
Monitoring sensitive signing or authentication operations.
Planning replacement, revocation, and recovery according to the keyβs purpose.
A password or passphrase may protect a stored private key, but it is not the key itself.
The consequences of loss or theft depend on the keyβs role:
Replacing a compromised key helps protect future use, but it cannot undo information already exposed. Likewise, compromising a long-term TLS authentication key does not automatically reveal past sessions protected by forward secrecy.
Build Practical Cybersecurity Skills
Understanding key roles gives you a foundation for studying PKI, secure connections, authentication, and CompTIA Security+ cryptography concepts. Applying those ideas helps reveal where you still need practice.
Pluralsight is an optional next step with guided security labs, feedback, assessments, and certification practice resources to help turn that understanding into practical skills.
Affiliate notice: Some links may earn a commission. Thanks for your support.
What Is RSA Encryption, and How Does It Work? (Explained Clearly)
Next
FAQ
Quick answers to the questions people usually ask about this topic.
How can I check that a public key really belongs to the right person?
Compare its fingerprint, a compact value derived from the public key, through a trusted independent channel. For example, confirm an SSH serverβs fingerprint with its administrator before accepting an unfamiliar host key. A fingerprint received alongside an untrusted key does not independently establish authenticity. For HTTPS, browsers instead validate certificates, including their trust chain and website name.
Can you recover a lost private key from its public key?
Not feasibly when secure algorithms, suitable key sizes, and correct implementations are used. Many systems can derive or extract the public key from private-key material, but the reverse is designed to be computationally impractical. If a private key is lost, recovery requires an existing backup or another recovery mechanism, not just the public key.
How do I tell whether a key file contains a public or private key?
Check the fileβs format and label rather than relying only on its extension. For example, OpenSSH commonly stores a public key in a file ending in .pub, while text-encoded private keys may contain a header such as -----BEGIN OPENSSH PRIVATE KEY----- or -----BEGIN PRIVATE KEY-----. A .pem extension alone is not enough to tell. Never paste a suspected private key into an online checker; inspect it locally with trusted tools.
Does changing a private keyβs passphrase replace the key?
No. Changing the passphrase normally changes how the stored private-key file is protected, not the underlying key pair. If someone has copied the key and knows its old passphrase, changing your copyβs passphrase does not disable theirs. Suspected compromise calls for a new key pair and removal or revocation of trust in the old key wherever it is used.
Should I reuse the same public and private key pair across different services?
Separate key pairs are generally preferable for different purposes or security boundaries. Reusing one private key increases the impact of a compromise and can make replacement harder. Keep signing, encryption, and authentication keys separate where the system supports it; not every algorithm or key is suitable for all three tasks.
If a websiteβs private key is stolen, can attackers decrypt old HTTPS traffic?
Not automatically. With forward secrecy, recorded sessions cannot be decrypted merely by later obtaining the serverβs long-term authentication key. Typical certificate-authenticated TLS 1.3 connections use a separate ephemeral key exchange for this protection. However, stolen traffic secrets or compromise of an endpoint can still expose data, and some older TLS configurations lack forward secrecy. See the TLS 1.3 specification for the protocol details.
How can I practice public-key cryptography concepts for CompTIA Security+?
Use an isolated practice environment to generate a test key pair, configure SSH authentication, inspect a certificate, and observe what happens when signed data changes. Use disposable keys, not production credentials. For structured hands-on learning, explore Pluralsight as an optional next step, with guided security labs, feedback, assessments, and practice exams to help identify gaps and focus your certification preparation.
Affiliate link β I may earn a commission at no additional cost to you.
Jay's Recommendation
Turn understanding into hands-on confidence
You've built the foundations. Pluralsight adds opportunities to practice in guided security labs, get feedback, and check your knowledge with assessments and practice exams, so your next step is more than another video.
π Put concepts to workBuild practical skills with guided security labs and feedback.
π―Find your weak spotsUse assessments to focus on what needs more work.
πCheck your understandingUse practice exams to guide your certification preparation.
π§Give study sessions directionOrganize further learning with curated paths and progress tracking.