mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Adds basic authentication logic.
+ Users need to be registered in order to send appointments (free registration for now) + The tower gives them a number of appointments to work with + Non-registered users and users with no enough appoitnemnts slots return the same error (to avoid proving) - Authentication does not cover get_* requests yet - No tests - No docs
This commit is contained in:
@@ -6,3 +6,6 @@ LOCATOR_LEN_BYTES = LOCATOR_LEN_HEX // 2
|
||||
HTTP_OK = 200
|
||||
HTTP_BAD_REQUEST = 400
|
||||
HTTP_SERVICE_UNAVAILABLE = 503
|
||||
|
||||
# Temporary constants, may be changed
|
||||
ENCRYPTED_BLOB_MAX_SIZE_HEX = 2 * 2048
|
||||
|
||||
@@ -315,3 +315,22 @@ class Cryptographer:
|
||||
"""
|
||||
|
||||
return pk.point() == rpk.point()
|
||||
|
||||
# TODO: UNITTEST
|
||||
@staticmethod
|
||||
def get_compressed_pk(pk):
|
||||
"""
|
||||
Computes a compressed, hex encoded, public key given a ``PublicKey`` object.
|
||||
|
||||
Args:
|
||||
pk(:obj:`PublicKey`): a given public key.
|
||||
|
||||
Returns:
|
||||
:obj:`str`: A compressed, hex encoded, public key (33-byte long)
|
||||
"""
|
||||
|
||||
if not isinstance(pk, PublicKey):
|
||||
logger.error("The received data is not a PublicKey object")
|
||||
return None
|
||||
|
||||
return hexlify(pk.format(compressed=True)).decode("utf-8")
|
||||
|
||||
Reference in New Issue
Block a user