base things for rsa notes, still missing last example in rsa.md

This commit is contained in:
shockrahwow 2019-09-26 11:44:12 -07:00
parent 942ed082f8
commit e12689ff43
2 changed files with 29 additions and 8 deletions

View File

@ -16,3 +16,11 @@ define gcd(a,b) {
return a;
}
define euclid(a, b) {
while(b != 0) {
t = b;
b = a % b;
a = t;
}
return a;
}

View File

@ -1,23 +1,23 @@
# Procedure
We have 4 primary values that we deal with:
Example using 3 values:
* p = 3
* q = 17
* e = 15
* m = 3
* p
* q
* e
* m
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.
`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
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
@ -38,3 +38,16 @@ The reverse of this is the following:
```
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_.