-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneratePrivateSecret.py
38 lines (26 loc) · 1.01 KB
/
generatePrivateSecret.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import constants
import paderson_commitment
# this is not cryptographically secure, use secrets library if time permits
import random
def generatePrivateSecret():
# # print("\nGenerating Private Secret")
g = constants.SHARED_BASE
p = constants.SHARED_PRIME
# choose a random number Xi
# Xi = random.randint(constants.RAND_NUMBER_LOWER_BOUND, constants.RAND_NUMBER_UPPER_BOUND)
Xi = paderson_commitment.generate_a()
# privateSecret = (g ** Xi) % p
privateSecret = paderson_commitment.generate_h(g,p,Xi)
# DEBUG INFO:
# # print("\n")
# # print("DEBUG: Shared Base: {}".format(g))
# # print("DEBUG: Shared Prime: {}".format(p))
# # print("DEBUG: Exponent: {}".format(Xi))
# # print("DEBUG: Private Secret: {}".format(privateSecret))
# # print("\n")
print('')
print("Shared Base: {}".format(g))
print("Shared Prime: {}".format(p))
print("Exponent: {}".format(Xi))
print("Private Secret: {}".format(privateSecret))
return privateSecret, Xi