Project consists of scripts for Cryptologic Protocol Theory class. It's meant to support student's workflow through out the class.
elem.py <modulo>
- elements of a group
gcd.py <a_number> <b_number>
- Greatest common dividor (GCD)
eucgcd.py <a_number> <b_number>
- Euclidean Algorithm (GCD)
ferm.py <number_to_test>
or ferm.py <number_to_test> <n_times>
- Fermant's test
gen.py <element> <modulo>
- tests if element is a generator
findgen.py <modulo>
- finds all generators of group
phi.py <number>
or phi.py <prime_factor> <prime_factor> ...
- Euler's function
inv.py <element> <modulo>
- inverse element
order.py <modulo>
- order of a group
order.py <element> <modulo>
- order of an element
pow.py <base> <power>
or pow.py <base> <power> <modulo>
- power
mod.py <number> <modulo>
- modulo
possibleSquares.py <modulo>
- finds possible squares in Field
elem.py <modulo>
- prints out elements of additive and multiplicative groupZ<modulo>
example: elem.py 12
gcd.py <a_number> <b_number>
- finds GCD
example: gcd.py 9 7
eucgcd.py <a_number> <b_number>
- finds GCD with Euclidean algorithm
example: eucgcd.py <33> <12>
ferm.py <number_to_test>
- tests if anumber
is a prime number through Fermant's testferm.py <number_to_test> <n_times> - runs Fermant's test
<n_times>`
example: ferm.py 69
will run test only once or ferm.py 69 3
will run test 3 times
The generator is and element such that if you do element^1 than element^2 and so on, it will generate all elements in the group. The group Z*q has phi(phi(q)) generators, ONLY if q is a prime!!! The only possible orders of an element are divisors of the Order of the group. Only these possible orders are necessary to test if testing an element to be a generator. If at the possible order is the element congruent to 1 than this element is not a generator. However, if the element is congruent to 1 at the order of phi(q) than the element is a generator.
gen.py <element> <modulo>
- test if<element>
is a generator inZ*<modulo>
gen.py <-t | --theory>
- prints out some basic theory
example: gen.py 3 10
findgen.py <modulo>
- test all elements if they are a generator inZ*<modulo>
example: findgen.py 11
phi.py <number>
- calculates Euler's function for<number>
phi.py <prime_factor> <prime_factor> ...
- calculates Euler's function by prime factors of a number
example: phi.py 60
or phi.py 2 2 3 5
Second usage is filled with prime factorization 60 = 2^2 * 3 * 5
Inverse is a number a(^-1)
such that: a * a^(-1) = 1 (mod n)
.
Inverse exist ONLY if a and n are comprime, means GCD(a,n) = 1 !!!
inv.py <element> <modulo>
- finds inverse to<element>
inZ*<modulo>
if existsinv.py <-t | --theory>
- shows theory
example: inv.py 5 12
- gives and inverse of 5 in modulo 12 (only multiplicative group)
inv.py --theory
- prints theory
Order of a group says how many elements group has. Order of an element says how many elements of a group can this element generate. The only possible orders of an element are divisors of Order of a group. Only these possible orders are necessary to test if testing an element to be a generator.
order.py <modulo>
- prints out order of a grouporder.py <element> <modulo>
- prints out order of an element in a grouporder.py <-t | --theory>
- prints out basic theory
example: order.py 69
or order.py 3 69
or order.py -t
pow.py <base> <power>
pow.py <base> <power> <modulo>
example: pow.py 69 2
- computes 69^2
pow.py 69 2 16
- computes 69^2 mod 16
mod.py <number> <mod>
example: mod.py 69 60
Injective (one-to-one) function is such that no two x map to same y
Surjective (onto) function is such that every y has AT LEAST one x
Bijective (combination of both) function is such that every y has EXACTLY one x
func.py
- shows some basic theory about functions
complex.py
- will show some basic info about computing complexity of an algorithm
In order to run above commands as shown you need to have installed python interpret and either be in current directory with scripts or have path to them set in system variable $PATH
(on Windows)
For faster workflow type only first few letters and press TAB
key for auto-compltion. This way you never have to type ".py" at least.
You don't have to type python
or python3
unless you want to use that specific version.
Feel free to contribute 🔧 Made with ❤️ in Czechia