Tool Pocket
Reset
Back

🔑 Public-key generator

Generate a pair of public and private keys. The keys can be used for encryption, decryption, signing, and verification.

Usage

  • Select options.

    OptionDescription
    AlgorithmKey pairs serve different purposes depending on the algorithm, and most algorithms are tailored for specific use cases. Details will be explained later.
    FormatPEM: A Base64-encoded text format for storing cryptographic keys and certificates, often wrapped with header/footer lines like -----BEGIN PUBLIC KEY-----. JWK: A JSON-based format for representing cryptographic keys, used especially in web applications and JWTs.
    Public exponentIn RSA, the public exponent (often denoted as ee) is part of the public key, used during encryption or signature verification. e=65537e=65537 is most commonly used.
    HashA hash function is used to compress a message into a fixed-size digest before signing it (or verifying it) with a public-key algorithm.
    Modulus bit lengthThis is the bit length of the RSA modulus n=pimesqn = p imes q, where pp and qq are prime numbers. Greater bit length means better security, but slower operations.
    Named curveThis is a predefined set of parameters for an elliptic curve used in cryptography, identified by a standard name.
  • Click Regenerate button. The keys will be generated.

  • Download the keys.

Public and Private Keys: Explanation

In public-key cryptography (also called asymmetric cryptography), two keys are used: a public key and a private key.

  • The public key is shared openly and used for encrypting messages or verifying digital signatures.
  • The private key is kept secret and used for decrypting messages or creating digital signatures.

This system allows secure communication, digital signatures, and key exchange—even over insecure networks.

🧠 Algorithm Overview

Different cryptographic algorithms use different mathematical foundations and are optimized for specific purposes. Here's a brief explanation of the listed algorithms:

AlgorithmKey TypeBased OnPrimary Use
RSASSA-PKCS1-v1_5RSAInteger factorizationDigital signatures
RSA-PSSRSAInteger factorization (with probabilistic padding)Secure digital signatures (improved over RSASSA)
RSA-OAEPRSAInteger factorization (with padding)Secure message encryption
ECDSAECC (Elliptic Curve Cryptography)Elliptic curvesDigital signatures (efficient & compact)
ECDHECCElliptic curvesKey exchange (establishing shared secrets)
Ed25519EdDSA (Edwards-curve Digital Signature Algorithm)Twisted Edwards curveHigh-speed, highly secure digital signatures. Since it is not officially supported yet, many browsers do not support it.

🔢 RSA-based Cryptography (RSA Family)

RSA is one of the most well-known public-key cryptographic systems. It is based on the mathematical difficulty of factoring large integers into their prime components.

Key Generation

  1. Select two large prime numbers: pp and qq.
  2. Compute the modulus: n=pqn = pq.
  3. Calculate Euler’s totient function: phi(n)=(p1)(q1)phi(n) = (p - 1)(q - 1)
  4. Choose a public exponent ee such that: 1<e<phi(n),quadgcd(e,phi(n))=11 < e < phi(n),quad gcd(e, phi(n)) = 1.
  5. Compute the private exponent dd such that: ed1modϕ(n)ed \equiv 1 \mod \phi(n).

Encryption and Decryption

Encryption (using the public key (e,n)(e, n)): c=memodnc = m^e \mod n.

Decryption (using the private key (d,n)(d, n)): m=cdmodnm = c^d \mod n.

  • m is the plaintext message (as an integer),
  • c is the ciphertext,
  • e, d, and n are from the key pair.

🥚 ECC-based Cryptography (Elliptic Curve Cryptography)

ECC is a modern public-key cryptographic technique that is based on the mathematics of elliptic curves over finite fields. It achieves equivalent security with much smaller key sizes compared to RSA.

Elliptic Curve Equation

Over a prime field Fp\mathbb{F}_p, an elliptic curve is defined as: y2=x3+ax+bmodpy^2 = x^3 + ax + b \mod p

Where the curve is non-singular (i.e., it has no cusps or self-intersections), which requires:

4a3+27b2≢0modp4a^3 + 27b^2 \not\equiv 0 \mod p

Key Generation

  1. Choose a curve EE and a base point GG on the curve.
  2. Choose a private key dZnd \in \mathbb{Z}_n.
  3. Compute the public key: Q=dGQ = dG.
  • Here, G is a publicly known generator point,
  • d is a randomly chosen integer (private key),
  • Q is the resulting public key point on the curve. ​

📐 Security Basis: ECDLP

The Elliptic Curve Discrete Logarithm Problem (ECDLP) is the basis of ECC's security: Given P and Q=kP, find k\text{Given } P \text{ and } Q = kP, \text{ find } k

This problem is computationally infeasible with current algorithms for appropriately chosen curves.

RSA vs ECC Summary Table

FeatureRSAECC
Security BasisInteger factorizationElliptic curve discrete log
Typical Key Size2048–4096 bits256–521 bits
PerformanceSlowerFaster (especially in signing)
CompatibilityVery high (legacy systems)Increasing support (modern apps)
Use CasesTLS, email, PGPMobile apps, blockchain, SSH