base things for rsa notes, still missing last example in rsa.md
This commit is contained in:
parent
942ed082f8
commit
e12689ff43
@ -16,3 +16,11 @@ define gcd(a,b) {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define euclid(a, b) {
|
||||||
|
while(b != 0) {
|
||||||
|
t = b;
|
||||||
|
b = a % b;
|
||||||
|
a = t;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
# Procedure
|
# Procedure
|
||||||
|
|
||||||
|
We have 4 primary values that we deal with:
|
||||||
|
|
||||||
Example using 3 values:
|
* p
|
||||||
|
* q
|
||||||
* p = 3
|
* e
|
||||||
* q = 17
|
* m
|
||||||
* e = 15
|
|
||||||
* m = 3
|
|
||||||
|
|
||||||
There are a few components which must be calculated before we can safely determine a cipher text:
|
There are a few components which must be calculated before we can safely determine a cipher text:
|
||||||
|
|
||||||
`n = p * q` : note that `p` and `q` values should be primes in this case.
|
`n = p * q` : note that `p` and `q` values should be primes in this case.
|
||||||
|
|
||||||
`O(n) = (p - 1) * (q - 1)` is used later to verify that we have a value `d` which is the inverse of `e`. _We call this the quotient function_.
|
`Φ(n) = (p - 1) * (q - 1)` is used later to verify that we have a value `d` which is the inverse of `e`. _We call this the quotient function_.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Encryption
|
## Encryption
|
||||||
|
|
||||||
To produce a cipher text `C` we take `m` and raise it to the power of `e`(from earlier) then take the modulor of it by `n`:
|
To produce a cipher text `C` we take `m` and raise it to the power of `e`(from earlier) then take the modulo of it by `n`:
|
||||||
|
|
||||||
```
|
```
|
||||||
C = (m^e) % n
|
C = (m^e) % n
|
||||||
@ -38,3 +38,16 @@ The reverse of this is the following:
|
|||||||
```
|
```
|
||||||
M = (c^d) % n
|
M = (c^d) % n
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## E inverse e^1
|
||||||
|
|
||||||
|
To find `d` the following _must_ be true: `GCD(e, Φ(n)) == 1`.
|
||||||
|
If this is not the case then there is no `d` or `e^-1`.
|
||||||
|
|
||||||
|
|
||||||
|
> how do i actually this trash tho???
|
||||||
|
|
||||||
|
Let's say we have `e=17` and `Φ(n)=60`:
|
||||||
|
|
||||||
|
We know the GCD(17,60) == 1 [17 is prime] so we can find an `e` inverse.
|
||||||
|
_Check the notes at the bottom for an easy to rationalize method of verifying this_.
|
||||||
|
Loading…
Reference in New Issue
Block a user