# multorder

## 541 days ago by voloch

print is_prime(101) for a in range(1,10): print a, Mod(a,101).multiplicative_order()
 True 1 1 2 100 3 100 4 50 5 25 6 10 7 100 8 100 9 50 True 1 1 2 100 3 100 4 50 5 25 6 10 7 100 8 100 9 50
#It works only when g is prim root mod p def dlog(h,g,p): return log( Mod(h,p), Mod(g,p)) dlog(5,2,101)
 24 24
Mod(2,101)^24
 5 5
gp.nextprime(10000)
 10007 10007
p=107 #101, 103, 107, 109 print p li =[(i,Mod(i,p).multiplicative_order()) for i in range(1,p)] list_plot(li, color='red')
 107 107
def dlog(h,g,p): return log( Mod(h,p), Mod(g,p)) p=109 #101, 103, 107, 109 print p g = gp.lift(gp.znprimroot(p)) print g li = [(i,dlog(i,g,p)) for i in range(1,p-1)] list_plot(li, color='red')
 109 6 109 6
p=109 #101, 103, 107, 109 print p g = gp.znprimroot(p) print g li = [(i,gp.lift(g^i)) for i in range(1,p-1)] list_plot(li, color='red')
 109 Mod(6, 109) 109 Mod(6, 109)
#diffie hellman p=gp.nextprime(10^100) print p #g = gp.znprimroot(p) g = Mod(2,p) print g a = 9005 #Alice's secret key b= 3 #Bob's secret key A = g^a #Alice sends this to Bob B = g^b # Bob sends this to Alice print A print B print (A^b == B^a) print A^b
 100000000000000000000000000000000000000000000000000000000000000000000000\ 00000000000000000000000000267 2 374408148146328115569966607423060328083578457773249608251829744472113398\ 1529745790698568359165165816 8 True 661675066781977167666678476536743352362013368597765843275434349493347224\ 8278188423132323764657822374 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000267 2 3744081481463281155699666074230603280835784577732496082518297444721133981529745790698568359165165816 8 True 6616750667819771676666784765367433523620133685977658432754343494933472248278188423132323764657822374
p=gp.nextprime(10^30) print p g = gp.znprimroot(p) print g
 1000000000000000000000000000057 Mod(5, 1000000000000000000000000000057) 1000000000000000000000000000057 Mod(5, 1000000000000000000000000000057)