#NEWLINE# def _sign( self , M , K ) : #NEWLINE# #INDENT# if ( not hasattr ( self , 'x' ) ) : #NEWLINE# #INDENT# raise error ( 'Private key not available in this object' ) #NEWLINE# #UNINDENT# p1 = ( self . p - 1 ) #NEWLINE# if ( GCD ( K , p1 ) != 1 ) : #NEWLINE# #INDENT# raise error ( 'Bad K value: GCD(K,p-1)!=1' ) #NEWLINE# #UNINDENT# a = pow ( self . g , K , self . p ) #NEWLINE# t = ( ( M - ( self . x * a ) ) % p1 ) #NEWLINE# while ( t < 0 ) : #NEWLINE# #INDENT# t = ( t + p1 ) #NEWLINE# #UNINDENT# b = ( ( t * inverse ( K , p1 ) ) % p1 ) #NEWLINE# return ( a , b )