Notes on RSA and Diffie-Hellman
1. Mathematical Background of RSA and Diffie-Hellman
RSA
- Prime Factorization: The problem of integer factorization.
- Diffie-Hellman: The discrete logarithm problem.
Let:
Define:
as a certain encryption form.
For example:
2. RSA Algorithm Steps
Choose two prime numbers:
Then:
(Computing the number of integers coprime to ( n ))
- Since ( p, q ) are primes, for all ( a \in \mathbb{Z}^+ ), if ( a < p ), then ( \gcd(a, p) = 1 ), where ( p ) is a prime.
- There are ( (p-1) ) and ( (q-1) ) numbers coprime to ( pq ).
- The total count of numbers up to ( n ) is ( n = p \cdot q ), and ( n ) is divisible by ( q ) and ( p ).
- The total count of numbers not coprime to ( n ) is ( p + q - 1 ).
- Therefore, ( \phi(n) = n - (q + p - 1) = pq - q - p + 1 = (p-1)(q-1) ).
Choose a public key ( e ):
For example:
Compute the private key ( d ):
Solving:
Public-private key pair:
- Public key: ( (e, n) = (7, 33) )
- Private key: ( (d, n) = (3, 33) )
3. Encryption and Decryption Process
Suppose the plaintext is ( m = 4 ), the ciphertext ( c ) is:
Calculation:
Decrypting to retrieve ( m ):
Calculation:
4. Proof of Correctness of Decryption
The encryption and decryption rely on the following equation:
Thus, we have:
From the encryption formula:
Using the decryption formula:
Substituting ( c ) from the encryption equation:
Consolidating the exponent:
Since ( e \cdot d = 1 + k \cdot \phi(n) ):
Applying Euler’s theorem:
Simplifying:
Since ( m^{\phi(n)} \equiv 1 ):
Thus, decryption is correct.
LWD:
$$
\left{ \left(a_i, \langle a_i, s \rangle + e_i \right) : s \gets \mathbb{Z}_q^n, a_i \gets \mathbb{Z}q^n, e_i \gets \chi \right}{i=1}^m
$$
- ( \mathbb{Z} = \mathbb{Z}/q \mathbb{Z} ) represents a finite ring modulo ( q ).
- ( \chi ) is a probability distribution over ( \mathbb{Z} ), used to generate “small numbers” (noise).
- Uniform Distribution: ( \chi ) randomly generates integer values from the range [−B, B] (e.g., [−5,5]), where ( B \ll q/2 ).
The assumption ( B \ll q/2 ) ensures that the noise ( e_i ) does not obscure the modulated result during decryption. - Discrete Gaussian Distribution: Another common distribution, denoted as ( D_{\mathbb{Z}, \sigma} ), with standard deviation ( \sigma ), used to generate near-zero random noise values.
( a \gets D ): a is randomly sampled (or generated) from probability distribution D.
( a \gets S ): When S is a finite set, a is randomly and uniformly selected from S.
( a_i \in \mathbb{Z}_q^n ): This denotes an ( n )-dimensional vector space modulo ( q ), where each component belongs to ( \mathbb{Z}_q ).
预览: