Tidy up
This commit is contained in:
103 files changed
+3663
-3779
No files matched your search
@@ -21,19 +21,17 @@
|
||||
### Euler Totient Function
|
||||
|
||||
- Integers $a$ and $m$ are *relatively prime* if they do not share a divisor (except 1)
|
||||
- $gcd(a,m) = 1$
|
||||
- $gcd(a,m) = 1$
|
||||
- The **Euler totient** $\Phi$ is the number of integers in $\mathbb{Z}_m = \{0,1,...m-1\}$ for which $gcd(a,m)=1$
|
||||
- For example $\Phi(9)=6$ as:
|
||||
- $gcd(1,9)=1$ :white_check_mark:
|
||||
- $gcd(2,9)=1$ :white_check_mark:
|
||||
- $gcd(3,9)=3$ ❌
|
||||
- $gcd(4,9)=1$ :white_check_mark:
|
||||
- $gcd(5,9)=1$ :white_check_mark:
|
||||
- $gcd(6,9)=3$ ❌
|
||||
- $gcd(7,9)=1$ :white_check_mark:
|
||||
- $gcd(8,9)=1$ :white_check_mark:
|
||||
|
||||
###
|
||||
- For example $\Phi(9)=6$ as:
|
||||
- $gcd(1,9)=1$ :white_check_mark:
|
||||
- $gcd(2,9)=1$ :white_check_mark:
|
||||
- $gcd(3,9)=3$ ❌
|
||||
- $gcd(4,9)=1$ :white_check_mark:
|
||||
- $gcd(5,9)=1$ :white_check_mark:
|
||||
- $gcd(6,9)=3$ ❌
|
||||
- $gcd(7,9)=1$ :white_check_mark:
|
||||
- $gcd(8,9)=1$ :white_check_mark:
|
||||
|
||||
#### Integer Factorisation
|
||||
|
||||
@@ -64,19 +62,19 @@ $$
|
||||
#### Fermat’s Little Theorem
|
||||
|
||||
- Fermat’s little theorem states that for some prime $p$, and any integer $a$:
|
||||
- $a^{p-1} \equiv 1 \space (mod \space p)$
|
||||
- Also note that $a^{p-1} = a\cdot a^{p-2} \equiv 1 \space (mod \space p)$
|
||||
- Therefore $a^{p-2}$ is actually the inverse of $a\space (mod \space p)$
|
||||
- It follows that $a^p \equiv p \space (mod \space p)$
|
||||
- $a^{p-1} \equiv 1 \space (mod \space p)$
|
||||
- Also note that $a^{p-1} = a\cdot a^{p-2} \equiv 1 \space (mod \space p)$
|
||||
- Therefore $a^{p-2}$ is actually the inverse of $a\space (mod \space p)$
|
||||
- It follows that $a^p \equiv p \space (mod \space p)$
|
||||
|
||||
#### Euler’s Theorem
|
||||
|
||||
- Generalisation of Fermat’s little theorem, not exclusive to primes
|
||||
- $a^{\Phi(m)} \equiv 1 \space (mod \space m)$
|
||||
- If $gcd(a,m)=1$
|
||||
- $a^{\Phi(m)} \equiv 1 \space (mod \space m)$
|
||||
- If $gcd(a,m)=1$
|
||||
- This works for any integer ring $\mathbb{Z}_m$
|
||||
- We can see that FLT is a special case of this
|
||||
- $\Phi(p) = (p-1) \therefore a^{\Phi(p)} = a^{p-1} \equiv 1 \space (mod \space p)$
|
||||
- We can see that FLT is a special case of this
|
||||
- $\Phi(p) = (p-1) \therefore a^{\Phi(p)} = a^{p-1} \equiv 1 \space (mod \space p)$
|
||||
|
||||
## RSA Key Generation
|
||||
|
||||
@@ -86,7 +84,7 @@ $$
|
||||
4. Choose a value $e\in \{2, ..., \Phi(n) -1\}$ where $gcd(\Phi(n),e)=1$
|
||||
5. Compute $d$ where $d\cdot e \equiv 1 \space (mod \space \Phi(n))$
|
||||
|
||||

|
||||

|
||||
|
||||
$d$ is very easy to calculate if you know $p$ and $q$
|
||||
|
||||
@@ -97,29 +95,29 @@ $d$ is very easy to calculate if you know $p$ and $q$
|
||||
##### Encryption
|
||||
|
||||
- Now we have a public key $(3, 187)$ and private key $107$
|
||||
- Encryption and decryption is performed by:
|
||||
- $x^e \equiv y \space (mod \space n)$
|
||||
- $y^d \equiv x \space (mod \space n)$
|
||||
- Encryption and decryption are performed by:
|
||||
- $x^e \equiv y \space (mod \space n)$
|
||||
- $y^d \equiv x \space (mod \space n)$
|
||||
|
||||

|
||||
|
||||
#### Proof
|
||||
|
||||
- We want to show that $(x^e)^d = x^{ed} \equiv x \space (mod \space n)$
|
||||
- Let’s assume $gcd(x,n)=1$ So Euler’s theorem applies
|
||||
- $e\cdot d=1\space (mod \space \Phi(n))$
|
||||
- $\therefore e\cdot d = 1 + k\cdot \Phi(n)$
|
||||
- $x^{e\cdot d} = x^{1+k\cdot \Phi(n)} = x\cdot x^{k+\Phi(n)}$
|
||||
- $x\cdot (x^{\Phi(n)})^k=x\cdot(1)^k=x$
|
||||
- Let’s assume $gcd(x,n)=1$, so Euler’s theorem applies
|
||||
- $e\cdot d=1\space (mod \space \Phi(n))$
|
||||
- $\therefore e\cdot d = 1 + k\cdot \Phi(n)$
|
||||
- $x^{e\cdot d} = x^{1+k\cdot \Phi(n)} = x\cdot x^{k+\Phi(n)}$
|
||||
- $x\cdot (x^{\Phi(n)})^k=x\cdot(1)^k=x$
|
||||
|
||||
### Why is RSA Secure
|
||||
|
||||
- We’d like the message $x$ based on some ciphertext $y$, given the public key $e$:
|
||||
- $y \equiv ?^d \space (mod \space n)$
|
||||
- $x \equiv y^? \space (mod \space n)$
|
||||
- $y \equiv ?^d \space (mod \space n)$
|
||||
- $x \equiv y^? \space (mod \space n)$
|
||||
- It can be fairly easy to calculate $d$:
|
||||
- $e\cdot d \equiv q \space (mod \space \Phi(n))$
|
||||
- $\Phi(n) = (p-1)(q-1)$
|
||||
- $e\cdot d \equiv q \space (mod \space \Phi(n))$
|
||||
- $\Phi(n) = (p-1)(q-1)$
|
||||
- As an attacker we only have access to $e$ and $d$
|
||||
|
||||
### Exponentiation
|
||||
@@ -129,7 +127,7 @@ x^4 = x^2 \cdot x^2 \\
|
||||
x^8 = x^4 \cdot x^4
|
||||
$$
|
||||
|
||||
When calculating a exponent raised to a power of two, we can use previously calculated values.
|
||||
When calculating an exponent raised to a power of two, we can use previously calculated values.
|
||||
|
||||
##### Binary Exponentiation
|
||||
|
||||
@@ -158,8 +156,7 @@ $$
|
||||
##### Computational Complexity
|
||||
|
||||
- What is the computational complexity of exponentiation?
|
||||
- For a 2048 key:
|
||||
- $X^{2^{2048}}$ - A ridiculously big number
|
||||
- Where as using square and multiply
|
||||
- $2048=T$ we need $\frac{3T}{2}$ calculations
|
||||
|
||||
- For a 2048 key:
|
||||
- $X^{2^{2048}}$ - A ridiculously big number
|
||||
- Whereas using square and multiply
|
||||
- $2048=T$ we need $\frac{3T}{2}$ calculations
|
||||
Reference in new issue
Block a user