-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
41 lines (29 loc) · 1.38 KB
/
main.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
38
39
40
41
import argparse
import time
from utils.parser import parse_file_ecdlp, parse_file_ecdsa
from attacker.ecdsa_attacks import attack_ecdsa
from attacker.ecdlp_attacks import attack_ecdlp
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", help="Input file in JSON format", required=True)
parser.add_argument("-s", "--ecdsa", help="Launch the script in ECDSA mode", default=False, action="store_true")
parser.add_argument("-d", "--ecdlp", help="Launch the script in ECDLP mode", default=False, action="store_true")
args = parser.parse_args()
if args.ecdsa:
(signatures, curve, generator) = parse_file_ecdsa(args.input)
print(f"Curve: {curve}")
print(f"Generator: {generator}")
start_time = time.time()
attack_ecdsa(signatures, curve, generator)
print(f"Attack completed in {round(time.time() - start_time, 2)} seconds")
exit(1)
if args.ecdlp:
(public_key, curve, generator) = parse_file_ecdlp(args.input)
print(f"Curve: {curve}")
print(f"Generator: {generator}")
print(f"Public key: {public_key}")
start_time = time.time()
attack_ecdlp(public_key, curve, generator)
print(f"Attack completed in {round(time.time() - start_time, 2)} seconds")
exit(1)
print("Please specify a mode, -h for help")