mirror of
https://github.com/aljazceru/python-teos.git
synced 2026-02-02 13:14:33 +01:00
Refactors code to use appointment from common based on f4a1e34e2f4d75226c7e313b83ff5ae06c8c89ca
This commit is contained in:
@@ -5,7 +5,7 @@ from flask import Flask, request, abort, jsonify
|
||||
from pisa import HOST, PORT, logging
|
||||
from common.logger import Logger
|
||||
from pisa.inspector import Inspector
|
||||
from pisa.appointment import Appointment
|
||||
from common.appointment import Appointment
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
from common.constants import HTTP_OK, HTTP_BAD_REQUEST, HTTP_SERVICE_UNAVAILABLE, LOCATOR_LEN_HEX
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from queue import Queue
|
||||
|
||||
from pisa.responder import TransactionTracker
|
||||
from pisa.appointment import Appointment
|
||||
from common.appointment import Appointment
|
||||
|
||||
|
||||
class Builder:
|
||||
|
||||
@@ -7,7 +7,7 @@ from common.cryptographer import Cryptographer
|
||||
from pisa import errors
|
||||
import pisa.conf as conf
|
||||
from common.logger import Logger
|
||||
from pisa.appointment import Appointment
|
||||
from common.appointment import Appointment
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
logger = Logger("Inspector")
|
||||
@@ -309,12 +309,12 @@ class Inspector:
|
||||
|
||||
@staticmethod
|
||||
# Verifies that the appointment signature is a valid signature with public key
|
||||
def check_appointment_signature(appointment, signature, pk_der):
|
||||
def check_appointment_signature(appointment_data, signature, pk_der):
|
||||
"""
|
||||
Checks if the provided user signature is correct.
|
||||
|
||||
Args:
|
||||
appointment (:obj:`dict`): the appointment that was signed by the user.
|
||||
appointment_data (:obj:`dict`): the appointment that was signed by the user.
|
||||
signature (:obj:`str`): the user's signature (hex encoded).
|
||||
pk_der (:obj:`str`): the user's public key (hex encoded, DER format).
|
||||
|
||||
@@ -336,7 +336,7 @@ class Inspector:
|
||||
message = "empty signature received"
|
||||
|
||||
pk = Cryptographer.load_public_key_der(unhexlify(pk_der))
|
||||
valid_sig = Cryptographer.verify(Cryptographer.signature_format(appointment), signature, pk)
|
||||
valid_sig = Cryptographer.verify(Appointment.from_dict(appointment_data).serialize(), signature, pk)
|
||||
|
||||
if not valid_sig:
|
||||
rcode = errors.APPOINTMENT_INVALID_SIGNATURE
|
||||
|
||||
@@ -141,7 +141,7 @@ class Watcher:
|
||||
|
||||
logger.info("New appointment accepted", locator=appointment.locator)
|
||||
|
||||
signature = Cryptographer.sign(Cryptographer.signature_format(appointment.to_dict()), self.signing_key)
|
||||
signature = Cryptographer.sign(appointment.serialize(), self.signing_key)
|
||||
|
||||
else:
|
||||
appointment_added = False
|
||||
|
||||
Reference in New Issue
Block a user