tinycodinglm / sec /crypto-asymmetric.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
1.27 kB
opencode trace
System You are an expert cryptographer and programmer.

You are an expert cryptographer and programmer.

User

Explain asymmetric encryption for programming

Assistant

RSA: based on factoring difficulty.
Key gen: pick primes p,q. n=pq. phi=(p-1)(q-1). e=65537. d=e^{-1} mod phi.
Encrypt: c = m^e mod n. Decrypt: m = c^d mod n.
Key sizes: 2048-bit minimum (3072 for long-term security).

ECC (Elliptic Curve Cryptography): based on discrete log on elliptic curves.
256-bit ECC ≈ 3072-bit RSA security.
Curves: P-256 (NIST), Curve25519 (Bernstein), secp256k1 (Bitcoin).

Diffie-Hellman: key exchange over public channel.
ECDH: both parties compute shared secret = their_private * other_public point.
X25519: modern DH using Curve25519.

Digital signatures:

  • RSA-PSS: probabilistic, padding with random salt.
  • Ed25519: EdDSA on Curve25519. Fast, deterministic, no nonce reuse risk.
  • ECDSA: requires random nonce k. Nonce reuse breaks security.

Applications: TLS 1.3, SSH, Signal protocol, Bitcoin transactions.