 in such a way that it is easy to find a
 in such a way that it is easy to find a
 with order
 with order  .  We have already seen
in Section 2.5 that for every prime
.  We have already seen
in Section 2.5 that for every prime  there 
exists an element
 there 
exists an element  of order
 of order  , and we gave
Algorithm 2.5.16 for finding a primitive
root for any prime.  The significance of the proposition
below is that it suggests an algorithm for finding
a primitive root that is easier to use in practice when
, and we gave
Algorithm 2.5.16 for finding a primitive
root for any prime.  The significance of the proposition
below is that it suggests an algorithm for finding
a primitive root that is easier to use in practice when  is large, because it does not require factoring
is large, because it does not require factoring  .
Of course, one could also just use a random
.
Of course, one could also just use a random  for Diffie-Hellman; it is not essential that
for Diffie-Hellman; it is not essential that  generates
 
generates 
 .
.
 is a prime such that
 is a prime such that  is also prime.
Then the elements of
 is also prime.
Then the elements of 
 have order either
 have order either  ,
,  ,
, 
 , or
, or  .
. is prime, the group
 is prime, the group 
 has order
 has order
 .  By assumption, the prime
factorization of
.  By assumption, the prime
factorization of  is
 is 
 .  Let
.  Let 
 .  Then by Theorem 2.1.19,
.  Then by Theorem 2.1.19,  ,
so the order of
,
so the order of  is a divisor of
 is a divisor of  , which proves the
proposition.
, which proves the
proposition.
  
Given a prime  with
 with  prime, find an element of
order
 prime, find an element of
order  as follows.  If
 as follows.  If  has order
 has order  we are done.
If not,
 we are done.
If not,  has order
 has order  since
 since  doesn't have order
either
 doesn't have order
either  or
 or  .  Then
.  Then  has order
 has order  .
.
Let 
 .  
Then
.  
Then  is prime,
but
 is prime,
but  is not.  So we keep adding
 is not.  So we keep adding  to
 to  and
testing pseudoprimality using algorithms from
Section 2.4 
until we find that the next pseudoprime after
 and
testing pseudoprimality using algorithms from
Section 2.4 
until we find that the next pseudoprime after  is
is 
 
It turns out that
 pseudoprime and
 pseudoprime and  is also pseudoprime.
We find that
 is also pseudoprime.
We find that  has order
 has order  , so
, so  has
order
 has
order  modulo
 modulo  , and is hence a generator of
, and is hence a generator of 
 ,
at least assuming that
,
at least assuming that  is really prime.
 is really prime.  
The secret random numbers generated by Nikita and Michael are
 
and
 
Nikita sends
 
to Michael, and Michael sends
 
to Nikita. They agree on the secret key
 
sage: q = 93450983094850938450983409623 sage: q.is_prime() True sage: is_prime((q-1)//2) True sage: g = Mod(-2, q) sage: g.multiplicative_order() 93450983094850938450983409622 sage: n = 18319922375531859171613379181; m = 82335836243866695680141440300 sage: g^n 45416776270485369791375944998 sage: g^m 15048074151770884271824225393 sage: (g^n)^m 85771409470770521212346739540 sage: (g^m)^n 85771409470770521212346739540
William 2007-06-01