Asymmetric cryptography solves the key distribution problem: two parties who have never met can establish a secure channel. Today covers RSA, elliptic curve cryptography, digital signatures, and the certificate infrastructure that secures the web.
RSA security relies on the practical difficulty of factoring large numbers. Key generation: choose two large primes p and q, compute n = p*q, find e and d such that e*d ≡ 1 (mod φ(n)). Public key is (e, n), private key is (d, n). Encryption: c = m^e mod n. Decryption: m = c^d mod n. RSA-2048 requires factoring a 617-digit number — currently infeasible. RSA-4096 is preferred for new deployments.
ECC provides equivalent security to RSA with much smaller keys: 256-bit ECC ≈ 3072-bit RSA security. This means faster operations and smaller TLS handshakes. ECDSA signs data; ECDH exchanges keys. Curve25519 (designed by Daniel Bernstein) is the modern recommendation — it avoids the potential backdoored NIST curves and is extremely fast. Ed25519 signatures are used in SSH, TLS 1.3, and Signal.
Public Key Infrastructure (PKI) solves the problem of trusting public keys. A Certificate Authority (CA) signs a certificate binding a public key to an identity (domain name, organization). Your browser trusts 130+ root CAs. When you visit https://precisionaiacademy.com, TLS validates that the certificate was signed by a trusted CA and matches the domain name.
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
Ed25519PrivateKey
)
from cryptography.hazmat.primitives.serialization import (
Encoding, PublicFormat, PrivateFormat, NoEncryption
)
# Generate Ed25519 key pair (modern, fast, secure)
private_key = Ed25519PrivateKey.generate()
public_key = private_key.public_key()
# Sign a message
message = b'Precision AI Academy contract - April 2026'
signature = private_key.sign(message)
print(f'Signature: {signature.hex()[:32]}...')
# Verify signature
try:
public_key.verify(signature, message)
print('Signature VALID')
except Exception:
print('Signature INVALID')
# Serialize public key (for sharing)
pub_bytes = public_key.public_bytes(Encoding.PEM, PublicFormat.SubjectPublicKeyInfo)
print(pub_bytes.decode())
Build a simple secure message system: Party A generates an Ed25519 key pair and shares the public key. Party B signs a message and sends it with the signature. Party A verifies it. Extend to add AES-256-GCM encryption of the message content.