@@ -416,9 +416,6 @@ def bsgs(public_key, print_matrix=False, print_linear_factorization=True):
416416 # Print calculation message
417417 print ('Berechnung, bitte warten...' , end = '\r ' )
418418
419- # Calculation of g_i
420- g_i = modulo_inverse_multiplicative .mim (p , g , print_matrix , print_linear_factorization , 1 )
421-
422419 # Calculation of m
423420 m = ceil (sqrt (p - 1 ))
424421
@@ -438,15 +435,18 @@ def bsgs(public_key, print_matrix=False, print_linear_factorization=True):
438435 # Removal of the calculation message
439436 print (' ' * len ('Berechnung, bitte warten...' ), end = '\r ' )
440437
441- # The value of p must be identical in both keys
438+ # Calculation of g_i
439+ g_i = modulo_inverse_multiplicative .mim (p , g , print_matrix , print_linear_factorization , 1 )
440+
441+ # Check the local existence of d
442442 if not 'd' in locals ():
443443 print (f'Der zum öffentlichen Schlüssel K(pub) = {{p, g, e}} = {{{ p } , { g } , { e } }} zugehörige private Schlüssel '
444444 f'K(priv) = {{p, d}} konnte nicht mittels des Babystep-Giantstep-Algorithmus bestimmt werden.' )
445445 return - 1
446446
447447 # Calculation path output
448448 print (
449- f'Gegeben ist der öffentliche Schlüssel K(pub) = {{p, g, e}} = {{{ p } , { g } , { e } }}. Unter Verwendung des'
449+ f'Gegeben ist der öffentliche Schlüssel K(pub) = {{p, g, e}} = {{{ p } , { g } , { e } }}. Unter Verwendung des '
450450 f'Babystep-Giantstep-Algorithmus zur Berechnung des diskreten Logarithmus im endlichen Zahlenkörper wird '
451451 f'nachfolgend der private Schlüssel K(priv) = {{p, d}} bestimmt.' , end = '\n \n ' )
452452 print (
0 commit comments