MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / primitiveRoot

Function primitiveRoot

ciphers/elgamal_key_generator.py:19–27  ·  view source on GitHub ↗
(p_val)

Source from the content-addressed store, hash-verified

17# so I used 4.80 Algorithm in Handbook of Applied Cryptography(CRC Press, ISBN : 0-8493-8523-7, October 1996)
18# and it seems to run nicely!
19def primitiveRoot(p_val):
20 print("Generating primitive root of p")
21 while True:
22 g = random.randrange(3,p_val)
23 if pow(g, 2, p_val) == 1:
24 continue
25 if pow(g, p_val, p_val) == 1:
26 continue
27 return g
28
29
30def generateKey(keySize):

Callers 1

generateKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected