#NEWLINE# def deterministic_generate_k( msghash , priv ) : #NEWLINE# #INDENT# v = ( b'\x01' * 32 ) #NEWLINE# k = ( b'\x00' * 32 ) #NEWLINE# priv = encode_privkey ( priv , 'bin' ) #NEWLINE# msghash = encode ( hash_to_int ( msghash ) , 256 , 32 ) #NEWLINE# k = hmac . new ( k , ( ( ( v + b'\x00' ) + priv ) + msghash ) , hashlib . sha256 ) . digest ( ) #NEWLINE# v = hmac . new ( k , v , hashlib . sha256 ) . digest ( ) #NEWLINE# k = hmac . new ( k , ( ( ( v + b'\x01' ) + priv ) + msghash ) , hashlib . sha256 ) . digest ( ) #NEWLINE# v = hmac . new ( k , v , hashlib . sha256 ) . digest ( ) #NEWLINE# return decode ( hmac . new ( k , v , hashlib . sha256 ) . digest ( ) , 256 )