Advertisement
Guest User

Krys

a guest
Dec 6th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. ︠24b8a16a-3fd1-4898-bbe0-6f240f382b9ds︠
  2.  
  3. #p = next_prime(2^100)
  4. p = 233 #musi byc pierwsza
  5. F = GF(p)
  6. #g = F(primitive_root(p)) # g wszystko jedno jakie chyba
  7. g = F(3)
  8.  
  9. print "p =", p, "and g =", g
  10.  
  11. a = randrange(1000) # losowanie od 0 do p chyba
  12.  
  13. A = (g**a)%p
  14. print "public key A =", A
  15.  
  16. b = randrange(1000) # losowanie od 0 do p
  17. B = (g**b)%p
  18. sB = (A**b)%p
  19. sA = (B**a)%p
  20. print "public key B =", B
  21. print "private key sA = ", sA, "\nprivate key sB =", sB
  22.  
  23.  
  24. print "Is it the same private key?"
  25. sB == sA
  26.  
  27. #time discrete_log(A,g)
  28. ︡7765ce03-2665-4331-87dc-63f251e643ed︡{"stdout":"p = 233 and g = 3\n"}︡{"stdout":"public key A = 116\n"}︡{"stdout":"public key B = 103\n"}︡{"stdout":"private key sA = 49 \nprivate key sB = 49\n"}︡{"stdout":"Is it the same private key?\n"}︡{"stdout":"True\n"}︡{"done":true}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement