diff --git a/silkaj/cert.py b/silkaj/cert.py index 6347051737fefc5b5fa768bdc7ce9df2c7eb92c5..4ab28c472734572d896d72c60d3f895570d9d9f5 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -28,9 +28,9 @@ from silkaj import wot_tools as wt from silkaj.auth import auth_method from silkaj.blockchain import tools as bc_tools from silkaj.constants import ALL, DATE -from silkaj.crypto_tools import is_pubkey_and_check from silkaj.g1_monetary_license import license_approval from silkaj.network import client_instance, send_document +from silkaj.public_key import is_pubkey_and_check @click.command("cert", help="Send certification") diff --git a/silkaj/checksum.py b/silkaj/checksum.py index a7bfaa37e3c8c09fef95641cbb93559b8a9af4f0..8737a87ea532c3482ec29b1610f3e4e232c591ed 100644 --- a/silkaj/checksum.py +++ b/silkaj/checksum.py @@ -19,7 +19,7 @@ import sys import click from silkaj.auth import auth_method, has_auth_method -from silkaj.crypto_tools import ( +from silkaj.public_key import ( PUBKEY_CHECKSUM_PATTERN, PUBKEY_DELIMITED_PATTERN, gen_checksum, diff --git a/silkaj/money/balance.py b/silkaj/money/balance.py index a24fd26f74bf502f338a8107bd91bb3b908783e4..3309cb2a404d59ca501be60f174c36b818387709 100644 --- a/silkaj/money/balance.py +++ b/silkaj/money/balance.py @@ -22,8 +22,8 @@ from silkaj import tui from silkaj import wot_tools as wt from silkaj.auth import auth_method, has_auth_method from silkaj.blockchain.tools import get_head_block -from silkaj.crypto_tools import is_pubkey_and_check from silkaj.money import tools as m_tools +from silkaj.public_key import is_pubkey_and_check from silkaj.tools import get_currency_symbol diff --git a/silkaj/money/history.py b/silkaj/money/history.py index cffbfc1713dad12aa8cc0378fbd9363ebc5f0021..edd456a9f74d7a2ca221eb638976b906bafe793e 100644 --- a/silkaj/money/history.py +++ b/silkaj/money/history.py @@ -26,13 +26,13 @@ from pendulum import from_timestamp, now from silkaj import wot_tools as wt from silkaj.constants import ALL, ALL_DIGITAL -from silkaj.crypto_tools import check_pubkey_format, validate_checksum from silkaj.money.tools import ( amount_in_current_base, get_amount_from_pubkey, get_ud_value, ) from silkaj.network import client_instance +from silkaj.public_key import check_pubkey_format, validate_checksum from silkaj.tools import get_currency_symbol from silkaj.tui import Table, gen_pubkey_checksum diff --git a/silkaj/money/transfer.py b/silkaj/money/transfer.py index 7390436cb7e0510cb1000c648d1050200ed7284f..8447b3130a361397be26d1e32e4d3a00d0b7825f 100644 --- a/silkaj/money/transfer.py +++ b/silkaj/money/transfer.py @@ -31,9 +31,7 @@ from duniterpy.documents import ( ) from duniterpy.key import SigningKey -from silkaj import auth, cli_tools -from silkaj import crypto_tools as ct -from silkaj import network, tools, tui +from silkaj import auth, cli_tools, network, public_key, tools, tui from silkaj.blockchain import tools as bc_tools from silkaj.constants import ( CENT_MULT_TO_UNIT, @@ -303,11 +301,11 @@ def check_transaction_values( f"Error : there should be less than {MAX_OUTPUTS - 1} outputs." ) for i, outputAddress in enumerate(outputAddresses): - if ct.check_pubkey_format(outputAddress): - outputAddresses[i] = ct.validate_checksum(outputAddress) + if public_key.check_pubkey_format(outputAddress): + outputAddresses[i] = public_key.validate_checksum(outputAddress) if outputBackChange: - if ct.check_pubkey_format(outputBackChange): - outputBackChange = ct.validate_checksum(outputBackChange) + if public_key.check_pubkey_format(outputBackChange): + outputBackChange = public_key.validate_checksum(outputBackChange) if enough_source: pubkey = tui.gen_pubkey_checksum(issuer_pubkey) tools.message_exit( diff --git a/silkaj/crypto_tools.py b/silkaj/public_key.py similarity index 100% rename from silkaj/crypto_tools.py rename to silkaj/public_key.py diff --git a/silkaj/tui.py b/silkaj/tui.py index 8eadf14e17dbd1bf695fec3858fd6bcaf75f6792..4813b81eb4d8eeb33ee16597171d46fb85dbe1ab 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -21,9 +21,7 @@ from typing import Dict, List, Optional, Union import click from texttable import Texttable -from silkaj import constants -from silkaj import crypto_tools as ct -from silkaj import wot_tools +from silkaj import constants, public_key, wot_tools VERT_TABLE_CHARS = ["─", "│", "│", "â•"] @@ -65,7 +63,7 @@ def gen_pubkey_checksum( `length` defaults to SHORT_PUBKEY_SIZE. """ short_pubkey = f"{pubkey[:length]}…" if short else pubkey - return f"{short_pubkey}:{ct.gen_checksum(pubkey)}" + return f"{short_pubkey}:{public_key.gen_checksum(pubkey)}" def send_doc_confirmation(document_name: str) -> None: diff --git a/silkaj/wot.py b/silkaj/wot.py index 50344aa479ec19c19dc4ca5228862b7f392a64c2..f0dc7d687abd8f4ad66b995004b3d24f5a48f315 100644 --- a/silkaj/wot.py +++ b/silkaj/wot.py @@ -24,8 +24,8 @@ from pendulum import from_timestamp, now from silkaj import wot_tools as wt from silkaj.blockchain.tools import get_blockchain_parameters from silkaj.constants import DATE -from silkaj.crypto_tools import is_pubkey_and_check from silkaj.network import client_instance, exit_on_http_error +from silkaj.public_key import is_pubkey_and_check from silkaj.tui import Table, gen_pubkey_checksum diff --git a/tests/money/test_history.py b/tests/money/test_history.py index f05b36330a7cbc1c7ab627f3d1bfe4446a2b5e78..cd18e22dbc7ed33b4dde9c4d789b58b2efac20d6 100644 --- a/tests/money/test_history.py +++ b/tests/money/test_history.py @@ -17,8 +17,8 @@ import pytest from silkaj import wot_tools from silkaj.constants import PUBKEY_MAX_LENGTH, PUBKEY_MIN_LENGTH, SHORT_PUBKEY_SIZE -from silkaj.crypto_tools import CHECKSUM_SIZE from silkaj.money import history +from silkaj.public_key import CHECKSUM_SIZE from tests.patched.blockchain_tools import currency from tests.patched.tx_history import patched_get_transactions_history from tests.patched.wot import patched_identities_from_pubkeys diff --git a/tests/test_crypto_tools.py b/tests/test_public_key.py similarity index 87% rename from tests/test_crypto_tools.py rename to tests/test_public_key.py index bba8ad85101bb9803c71f8571cb2e2d7bb5c1e5b..3849ebe343582f57640bbc978112dad25c75e2ab 100644 --- a/tests/test_crypto_tools.py +++ b/tests/test_public_key.py @@ -15,7 +15,7 @@ import pytest -from silkaj import crypto_tools +from silkaj import public_key # test gen_checksum @@ -26,7 +26,7 @@ from silkaj import crypto_tools ], ) def test_gen_checksum(pubkey, checksum): - assert checksum == crypto_tools.gen_checksum(pubkey) + assert checksum == public_key.gen_checksum(pubkey) # test validate_checksum @@ -45,10 +45,10 @@ does not match checksum 'KA'.\nPlease verify the public key.\n", def test_validate_checksum(pubkey, checksum, expected, capsys): pubkey_with_ck = f"{pubkey}:{checksum}" if not expected: - assert pubkey == crypto_tools.validate_checksum(pubkey_with_ck) + assert pubkey == public_key.validate_checksum(pubkey_with_ck) else: with pytest.raises(SystemExit) as pytest_exit: - crypto_tools.validate_checksum(pubkey_with_ck) + public_key.validate_checksum(pubkey_with_ck) assert capsys.readouterr().out == expected assert pytest_exit.type == SystemExit @@ -66,11 +66,11 @@ def test_validate_checksum(pubkey, checksum, expected, capsys): def test_check_pubkey_format(pubkey, display_error, expected, capsys): if isinstance(expected, str): with pytest.raises(SystemExit) as pytest_exit: - crypto_tools.check_pubkey_format(pubkey, display_error) + public_key.check_pubkey_format(pubkey, display_error) assert capsys.readouterr().out == expected assert pytest_exit.type == SystemExit else: - assert expected == crypto_tools.check_pubkey_format(pubkey, display_error) + assert expected == public_key.check_pubkey_format(pubkey, display_error) # test is_pubkey_and_check @@ -89,7 +89,7 @@ def test_check_pubkey_format(pubkey, display_error, expected, capsys): ], ) def test_is_pubkey_and_check(uid_pubkey, expected): - assert expected == crypto_tools.is_pubkey_and_check(uid_pubkey) + assert expected == public_key.is_pubkey_and_check(uid_pubkey) # test is_pubkey_and_check errors @@ -110,6 +110,6 @@ J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", ) def test_is_pubkey_and_check_errors(uid_pubkey, expected, capsys): with pytest.raises(SystemExit) as pytest_exit: - crypto_tools.is_pubkey_and_check(uid_pubkey) + public_key.is_pubkey_and_check(uid_pubkey) assert capsys.readouterr() == expected assert pytest_exit.type == SystemExit