[#2] Add methods sign and verify

This commit is contained in:
ilyas585 2025-02-11 10:03:29 +03:00
parent 97bc53c6f4
commit 4433fc425a
9 changed files with 102 additions and 10 deletions

View file

@ -0,0 +1,15 @@
import ecdsa
from hashlib import sha256
class Signer:
def sign_rfc6979(self, private_key: bytes, message: bytes) -> bytes:
if len(private_key) == 0 or private_key is None:
raise ValueError(f"Incorrect private_key: {private_key}")
# SECP256k1 is the Bitcoin elliptic curve
sk = ecdsa.SigningKey.from_string(private_key, curve=ecdsa.SECP256k1, hashfunc=sha256)
signature = sk.sign(message, sigencode=ecdsa.util.sigencode_string)
return signature