Lecture 9
Continue on Cyclic groups
Remind that .
, So
For , the order of , is the smallest positive such that .
In a general finite group
(identity)
If a group is cyclic
In a cyclic group, if , then a is a generator of .
Fact: is cyclic
, so generator , and ,
For example, is a generator for with .
If is a generator, , is onto.
What type of prime ?
- Large prime.
- If is very factorable, that is very bad.
- Pohlig-Hellman algorithm
- only need polynomial time to invert
- We want , where is prime. (Sophie Germain primes, or safe primes)
There are probably infinitely many safe prime and efficient to sample as well.
If is safe, generator.
Then is a subgroup;
It is cyclic with generator .
It is easy to find a generator.
- Pick
- Let . If , it is a generator of subgroup
Example:
we have a subgroup with generator and
def get_generator(p):
"""
p should be a prime, or you need to do factorization
"""
g=[]
for i in range(2,p-1):
k=i
sg=[]
step=p
while k!=1 and step>0:
if k==0:
raise ValueError(f"Damn, {i} generates 0 for group {p}")
sg.append(k)
k=(k*i)%p
step-=1
sg.append(1)
# if len(sg)!=(p-1): continue
g.append((i,[j for j in sg]))
return g
Diffie-Hellman assumption
If is a randomly sampled safe prime.
Denote safe prime as
Then
is the function condition when we do the encryption on cyclic groups.
Notes: is one-to-one, so