mirror of
https://github.com/aljazceru/python-teos.git
synced 2026-02-12 10:04:41 +01:00
Renamed constants and default file names for Pisa's private and public keys
This commit is contained in:
@@ -11,7 +11,7 @@ CLIENT_LOG_FILE = 'pisa.log'
|
|||||||
SUPPORTED_HASH_FUNCTIONS = ["SHA256"]
|
SUPPORTED_HASH_FUNCTIONS = ["SHA256"]
|
||||||
SUPPORTED_CIPHERS = ["AES-GCM-128"]
|
SUPPORTED_CIPHERS = ["AES-GCM-128"]
|
||||||
|
|
||||||
PUBLIC_KEY_FILE = "signing_key_pub.pem"
|
PISA_PUBLIC_KEY = "pisa_pk.pem"
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
logging.basicConfig(format='%(message)s', level=logging.INFO, handlers=[
|
logging.basicConfig(format='%(message)s', level=logging.INFO, handlers=[
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ from pisa.appointment import Appointment
|
|||||||
|
|
||||||
from apps.cli.blob import Blob
|
from apps.cli.blob import Blob
|
||||||
from apps.cli.help import help_add_appointment, help_get_appointment
|
from apps.cli.help import help_add_appointment, help_get_appointment
|
||||||
from apps.cli import DEFAULT_PISA_API_SERVER, DEFAULT_PISA_API_PORT, PUBLIC_KEY_FILE
|
from apps.cli import DEFAULT_PISA_API_SERVER, DEFAULT_PISA_API_PORT, PISA_PUBLIC_KEY
|
||||||
|
|
||||||
HTTP_OK = 200
|
HTTP_OK = 200
|
||||||
|
|
||||||
logger = Logger("Client")
|
logger = Logger("Client")
|
||||||
|
|
||||||
with open(PUBLIC_KEY_FILE, "r") as key_file:
|
with open(PISA_PUBLIC_KEY, "r") as key_file:
|
||||||
pubkey_pem = key_file.read().encode("utf-8")
|
pubkey_pem = key_file.read().encode("utf-8")
|
||||||
pisa_public_key = load_pem_public_key(pubkey_pem, backend=default_backend())
|
pisa_public_key = load_pem_public_key(pubkey_pem, backend=default_backend())
|
||||||
|
|
||||||
@@ -88,8 +88,6 @@ def add_appointment(args):
|
|||||||
try:
|
try:
|
||||||
r = requests.post(url=add_appointment_endpoint, json=appointment.to_json(), timeout=5)
|
r = requests.post(url=add_appointment_endpoint, json=appointment.to_json(), timeout=5)
|
||||||
|
|
||||||
print(r.text)
|
|
||||||
|
|
||||||
logger.info("{} (code: {}).".format(r.json(), r.status_code))
|
logger.info("{} (code: {}).".format(r.json(), r.status_code))
|
||||||
|
|
||||||
response_json = r.json()
|
response_json = r.json()
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ from cryptography.hazmat.primitives.asymmetric import ec
|
|||||||
|
|
||||||
|
|
||||||
# Simple tool to generate an ECDSA private key using the secp256k1 curve and save private and public keys
|
# Simple tool to generate an ECDSA private key using the secp256k1 curve and save private and public keys
|
||||||
# as signing_key_priv.pem and signing_key_pub.pem
|
# as 'pisa_sk.pem' 'and pisa_pk.pem', respectively.
|
||||||
|
|
||||||
FILE_NAME_PRIV = 'signing_key_priv.pem'
|
FILE_NAME_PRIV = 'pisa_sk.pem'
|
||||||
FILE_NAME_PUB = 'signing_key_pub.pem'
|
FILE_NAME_PUB = 'pisa_pk.pem'
|
||||||
|
|
||||||
|
|
||||||
def save_sk(sk, filename):
|
def save_sk(sk, filename):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ EXPIRY_DELTA = 6
|
|||||||
MIN_DISPUTE_DELTA = 20
|
MIN_DISPUTE_DELTA = 20
|
||||||
SERVER_LOG_FILE = 'pisa.log'
|
SERVER_LOG_FILE = 'pisa.log'
|
||||||
DB_PATH = 'appointments/'
|
DB_PATH = 'appointments/'
|
||||||
SIGNING_KEY_FILE = None
|
PISA_SECRET_KEY = 'pisa_sk.pem'
|
||||||
|
|
||||||
# PISA-CLI
|
# PISA-CLI
|
||||||
CLIENT_LOG_FILE = 'pisa.log'
|
CLIENT_LOG_FILE = 'pisa.log'
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from cryptography.hazmat.primitives.asymmetric import ec
|
|||||||
|
|
||||||
from pisa.logger import Logger
|
from pisa.logger import Logger
|
||||||
from pisa.cleaner import Cleaner
|
from pisa.cleaner import Cleaner
|
||||||
from pisa.conf import EXPIRY_DELTA, MAX_APPOINTMENTS, SIGNING_KEY_FILE
|
from pisa.conf import EXPIRY_DELTA, MAX_APPOINTMENTS, PISA_SECRET_KEY
|
||||||
from pisa.responder import Responder
|
from pisa.responder import Responder
|
||||||
from pisa.block_processor import BlockProcessor
|
from pisa.block_processor import BlockProcessor
|
||||||
from pisa.utils.zmq_subscriber import ZMQHandler
|
from pisa.utils.zmq_subscriber import ZMQHandler
|
||||||
@@ -27,10 +27,10 @@ class Watcher:
|
|||||||
self.zmq_subscriber = None
|
self.zmq_subscriber = None
|
||||||
self.responder = Responder()
|
self.responder = Responder()
|
||||||
|
|
||||||
if SIGNING_KEY_FILE is None:
|
if PISA_SECRET_KEY is None:
|
||||||
raise ValueError("No signing key provided. Please fix your pisa.conf")
|
raise ValueError("No signing key provided. Please fix your pisa.conf")
|
||||||
else:
|
else:
|
||||||
with open(SIGNING_KEY_FILE, "r") as key_file:
|
with open(PISA_SECRET_KEY, "r") as key_file:
|
||||||
privkey_pem = key_file.read().encode("utf-8")
|
privkey_pem = key_file.read().encode("utf-8")
|
||||||
self.signing_key = load_pem_private_key(privkey_pem, password=None, backend=default_backend())
|
self.signing_key = load_pem_private_key(privkey_pem, password=None, backend=default_backend())
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from test.simulator.utils import sha256d
|
|||||||
from test.simulator.transaction import TX
|
from test.simulator.transaction import TX
|
||||||
from test.unit.conftest import generate_block
|
from test.unit.conftest import generate_block
|
||||||
from pisa.utils.auth_proxy import AuthServiceProxy
|
from pisa.utils.auth_proxy import AuthServiceProxy
|
||||||
from pisa.conf import EXPIRY_DELTA, BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, SIGNING_KEY_FILE
|
from pisa.conf import EXPIRY_DELTA, BTC_RPC_USER, BTC_RPC_PASSWD, BTC_RPC_HOST, BTC_RPC_PORT, PISA_SECRET_KEY
|
||||||
|
|
||||||
logging.getLogger().disabled = True
|
logging.getLogger().disabled = True
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ APPOINTMENTS = 5
|
|||||||
START_TIME_OFFSET = 1
|
START_TIME_OFFSET = 1
|
||||||
END_TIME_OFFSET = 1
|
END_TIME_OFFSET = 1
|
||||||
|
|
||||||
with open(SIGNING_KEY_FILE, "r") as key_file:
|
with open(PISA_SECRET_KEY, "r") as key_file:
|
||||||
pubkey_pem = key_file.read().encode("utf-8")
|
pubkey_pem = key_file.read().encode("utf-8")
|
||||||
# TODO: should use the public key file instead, but it is not currently exported in the configuration
|
# TODO: should use the public key file instead, but it is not currently exported in the configuration
|
||||||
signing_key = load_pem_private_key(pubkey_pem, password=None, backend=default_backend())
|
signing_key = load_pem_private_key(pubkey_pem, password=None, backend=default_backend())
|
||||||
|
|||||||
Reference in New Issue
Block a user