Added create container grpc method
Signed-off-by: Ilyas Niyazov <i.niyazov@yadro.com>
This commit is contained in:
parent
9a1b5d778b
commit
f8465e5b99
34 changed files with 532 additions and 53 deletions
28
frostfs_sdk/cryptography/signer.py
Normal file
28
frostfs_sdk/cryptography/signer.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import ecdsa
|
||||
from hashlib import sha256, sha512
|
||||
|
||||
|
||||
class Signer:
|
||||
@staticmethod
|
||||
def sign_rfc6979(private_key: bytes, message: bytes) -> bytes:
|
||||
if len(private_key) == 0 or private_key is None:
|
||||
raise ValueError(f"Incorrect private_key: {private_key}")
|
||||
|
||||
sk = ecdsa.SigningKey.from_string(private_key, curve=ecdsa.NIST256p, hashfunc=sha256)
|
||||
|
||||
signature = sk.sign_deterministic(message)
|
||||
|
||||
return signature
|
||||
|
||||
@staticmethod
|
||||
def sign(private_key: bytes, message: bytes) -> bytes:
|
||||
if len(private_key) == 0 or private_key is None:
|
||||
raise ValueError(f"Incorrect private key: {private_key}")
|
||||
|
||||
sk = ecdsa.SigningKey.from_string(private_key, curve=ecdsa.NIST256p, hashfunc=sha512)
|
||||
signature = sk.sign(message)
|
||||
|
||||
# the first byte indicates the node version marker
|
||||
signature_with_marker = bytes([0x04]) + signature
|
||||
|
||||
return signature_with_marker
|
Loading…
Add table
Add a link
Reference in a new issue