[#2] Add methods sign and verify
This commit is contained in:
parent
97bc53c6f4
commit
4433fc425a
9 changed files with 102 additions and 10 deletions
15
frostfs_api/client/signer.py
Normal file
15
frostfs_api/client/signer.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue