[#2] Add methods sign and verify
Signed-off-by: ilyas585 <niyazov2023@gmail.com>
This commit is contained in:
parent
4433fc425a
commit
a51ef880fe
9 changed files with 225 additions and 15 deletions
39
tests/cryptography/test_key_extension.py
Normal file
39
tests/cryptography/test_key_extension.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import pytest
|
||||
|
||||
from tests.helpers.models import ClientCryptograpy
|
||||
from tests.helpers.convert import convert_bytes_format_127_to_256
|
||||
from tests.helpers.resources import WIF, PRIVATE_KEY
|
||||
|
||||
|
||||
@pytest.mark.crypto
|
||||
class TestKeyExtension:
|
||||
def test_get_private_key_from_wif_success(self, client_cryptography: ClientCryptograpy):
|
||||
private_key = client_cryptography.key_extension.get_private_key_from_wif(WIF)
|
||||
|
||||
assert len(private_key) == 32, f"Not correct len of private key, expected: 32 Actual: {len(private_key)} "
|
||||
assert isinstance(private_key, bytes), f"Not correct type of private key, Expected bytes, Actual: {type(private_key)}"
|
||||
assert private_key == bytes(convert_bytes_format_127_to_256(PRIVATE_KEY)), \
|
||||
f"Not match private key, Expected: {PRIVATE_KEY}, Actual: {private_key}"
|
||||
|
||||
def test_get_private_key_empty_wif(self, client_cryptography: ClientCryptograpy):
|
||||
with pytest.raises(ValueError, match="Empty"):
|
||||
client_cryptography.key_extension.get_private_key_from_wif("")
|
||||
|
||||
def test_get_private_key_incorrect_wif(self, client_cryptography: ClientCryptograpy):
|
||||
with pytest.raises(ValueError, match="Invalid checksum"):
|
||||
client_cryptography.key_extension.get_private_key_from_wif("AAAAAAABBBBBBBBBBBCCCCCCCDDDDDDDDDDDDDDDDD")
|
||||
|
||||
def test_get_public_key(self, client_cryptography: ClientCryptograpy):
|
||||
private_key = client_cryptography.key_extension.get_private_key_from_wif(WIF)
|
||||
public_key = client_cryptography.key_extension.get_public_key(private_key)
|
||||
|
||||
assert len(public_key) == 33, f"Not correct len of public key, expected: 33 Actual: {len(private_key)} "
|
||||
assert isinstance(public_key, bytes), f"Not correct type of public key, Expected bytes, Actual: {type(private_key)}"
|
||||
|
||||
def test_get_public_key_empty(self, client_cryptography: ClientCryptograpy):
|
||||
with pytest.raises(ValueError, match="Empty"):
|
||||
client_cryptography.key_extension.get_public_key(b"")
|
||||
|
||||
def test_get_public_key_invalid_private_key(self, client_cryptography: ClientCryptograpy):
|
||||
with pytest.raises(ValueError):
|
||||
client_cryptography.key_extension.get_public_key(b"invalid_private_key")
|
Loading…
Add table
Add a link
Reference in a new issue