bitaps-com / pybtc

Python bitcoin library
GNU General Public License v3.0
86 stars 37 forks source link

sign_message keeps giving same signature,, for the same private key and message #31

Closed legion2002 closed 2 years ago

legion2002 commented 2 years ago

Describe the bug When I try signing the same message with the same private key multiple times, the function keeps returning the same signature. But according to standard EDSA algorithms, the signatures would be different every time. Am I doing something wrong?

To Reproduce Steps to reproduce the behavior: import pybtc

pk = "Kz36wrYMg9cnKmpV6aucemPa1EAoxwKRo5DBsBML7dLbXbgcsE6K"

public = pybtc.private_to_public_key(pk) print("public = " + public)

a = pybtc.sign_message("6865790D0A", pk, hex=True) print(a) b = pybtc.verify_signature(a, public, "6865790D0A") print(b)

Additional context https://stackoverflow.com/questions/56520582/digital-signature-different-everytime/56527077#:~:text=The%20same%20data%20will%20give%20the%20same%20signature%20every%20time.

4tochka commented 2 years ago

Please read this document https://datatracker.ietf.org/doc/html/rfc6979

Bitcoin use rfc6979