[#2] Add methods sign and verify
This commit is contained in:
parent
97bc53c6f4
commit
4433fc425a
9 changed files with 102 additions and 10 deletions
18
frostfs_api/client/verifier.py
Normal file
18
frostfs_api/client/verifier.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import ecdsa
|
||||
from hashlib import sha256
|
||||
|
||||
|
||||
class Verifier:
|
||||
def verify_rfc6979(self, public_key: bytes, message: bytes, signature: bytes) -> bool:
|
||||
if len(public_key) == 0 or public_key is None:
|
||||
raise ValueError(f"Incorrect public key: {public_key}")
|
||||
|
||||
if message is None or signature is None:
|
||||
return False
|
||||
|
||||
vk = ecdsa.VerifyingKey.from_string(public_key, curve=ecdsa.SECP256k1, hashfunc=sha256)
|
||||
|
||||
try:
|
||||
return vk.verify(signature, message)
|
||||
except ecdsa.BadSignatureError:
|
||||
return False
|
Loading…
Add table
Add a link
Reference in a new issue