mirror of https://github.com/nucypher/nucypher.git
parent
3b43eac717
commit
0b697881a1
|
@ -82,7 +82,8 @@ from nucypher.crypto.powers import (
|
||||||
DelegatingPower,
|
DelegatingPower,
|
||||||
PowerUpError,
|
PowerUpError,
|
||||||
SigningPower,
|
SigningPower,
|
||||||
TransactingPower
|
TransactingPower,
|
||||||
|
TLSHostingPower,
|
||||||
)
|
)
|
||||||
from nucypher.crypto.signing import InvalidSignature
|
from nucypher.crypto.signing import InvalidSignature
|
||||||
from nucypher.crypto.splitters import key_splitter, signature_splitter, cfrag_splitter
|
from nucypher.crypto.splitters import key_splitter, signature_splitter, cfrag_splitter
|
||||||
|
@ -103,7 +104,7 @@ from nucypher.network.exceptions import NodeSeemsToBeDown
|
||||||
from nucypher.network.middleware import RestMiddleware
|
from nucypher.network.middleware import RestMiddleware
|
||||||
from nucypher.network.nodes import NodeSprout, TEACHER_NODES, Teacher
|
from nucypher.network.nodes import NodeSprout, TEACHER_NODES, Teacher
|
||||||
from nucypher.network.protocols import InterfaceInfo, parse_node_uri
|
from nucypher.network.protocols import InterfaceInfo, parse_node_uri
|
||||||
from nucypher.network.server import ProxyRESTServer, TLSHostingPower, make_rest_app
|
from nucypher.network.server import ProxyRESTServer, make_rest_app
|
||||||
from nucypher.network.trackers import AvailabilityTracker
|
from nucypher.network.trackers import AvailabilityTracker
|
||||||
from nucypher.policy.hrac import HRAC
|
from nucypher.policy.hrac import HRAC
|
||||||
from nucypher.policy.maps import TreasureMap, EncryptedTreasureMap, AuthorizedKeyFrag
|
from nucypher.policy.maps import TreasureMap, EncryptedTreasureMap, AuthorizedKeyFrag
|
||||||
|
|
|
@ -46,7 +46,8 @@ from nucypher.crypto.powers import (
|
||||||
KeyPairBasedPower,
|
KeyPairBasedPower,
|
||||||
SigningPower,
|
SigningPower,
|
||||||
CryptoPowerUp,
|
CryptoPowerUp,
|
||||||
DelegatingPower
|
DelegatingPower,
|
||||||
|
TLSHostingPower,
|
||||||
)
|
)
|
||||||
from nucypher.crypto.tls import generate_self_signed_certificate
|
from nucypher.crypto.tls import generate_self_signed_certificate
|
||||||
from nucypher.crypto.umbral_adapter import (
|
from nucypher.crypto.umbral_adapter import (
|
||||||
|
@ -54,7 +55,6 @@ from nucypher.crypto.umbral_adapter import (
|
||||||
secret_key_factory_from_seed,
|
secret_key_factory_from_seed,
|
||||||
secret_key_factory_from_secret_key_factory
|
secret_key_factory_from_secret_key_factory
|
||||||
)
|
)
|
||||||
from nucypher.network.server import TLSHostingPower
|
|
||||||
|
|
||||||
# HKDF
|
# HKDF
|
||||||
__INFO_BASE = b'NuCypher/'
|
__INFO_BASE = b'NuCypher/'
|
||||||
|
|
|
@ -25,7 +25,7 @@ from hexbytes import HexBytes
|
||||||
from nucypher.blockchain.eth.decorators import validate_checksum_address
|
from nucypher.blockchain.eth.decorators import validate_checksum_address
|
||||||
from nucypher.blockchain.eth.signers.base import Signer
|
from nucypher.blockchain.eth.signers.base import Signer
|
||||||
from nucypher.crypto import keypairs
|
from nucypher.crypto import keypairs
|
||||||
from nucypher.crypto.keypairs import DecryptingKeypair, SigningKeypair
|
from nucypher.crypto.keypairs import DecryptingKeypair, SigningKeypair, HostingKeypair
|
||||||
from nucypher.crypto.umbral_adapter import generate_kfrags, SecretKeyFactory, SecretKey, PublicKey
|
from nucypher.crypto.umbral_adapter import generate_kfrags, SecretKeyFactory, SecretKey, PublicKey
|
||||||
|
|
||||||
|
|
||||||
|
@ -290,3 +290,29 @@ class DelegatingPower(DerivedKeyBasedPower):
|
||||||
label_keypair = keypairs.DecryptingKeypair(private_key=label_privkey)
|
label_keypair = keypairs.DecryptingKeypair(private_key=label_privkey)
|
||||||
decrypting_power = DecryptingPower(keypair=label_keypair)
|
decrypting_power = DecryptingPower(keypair=label_keypair)
|
||||||
return decrypting_power
|
return decrypting_power
|
||||||
|
|
||||||
|
|
||||||
|
class TLSHostingPower(KeyPairBasedPower):
|
||||||
|
_keypair_class = HostingKeypair
|
||||||
|
provides = ("get_deployer",)
|
||||||
|
|
||||||
|
class NoHostingPower(PowerUpError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
not_found_error = NoHostingPower
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
host: str,
|
||||||
|
public_certificate=None,
|
||||||
|
public_certificate_filepath=None,
|
||||||
|
*args, **kwargs) -> None:
|
||||||
|
|
||||||
|
if public_certificate and public_certificate_filepath:
|
||||||
|
# TODO: Design decision here: if they do pass both, and they're identical, do we let that slide? NRN
|
||||||
|
raise ValueError("Pass either a public_certificate or a public_certificate_filepath, not both.")
|
||||||
|
|
||||||
|
if public_certificate:
|
||||||
|
kwargs['keypair'] = HostingKeypair(certificate=public_certificate, host=host)
|
||||||
|
elif public_certificate_filepath:
|
||||||
|
kwargs['keypair'] = HostingKeypair(certificate_filepath=public_certificate_filepath, host=host)
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -29,7 +29,7 @@ from mako.template import Template
|
||||||
|
|
||||||
from nucypher.blockchain.eth.utils import period_to_epoch
|
from nucypher.blockchain.eth.utils import period_to_epoch
|
||||||
from nucypher.config.constants import MAX_UPLOAD_CONTENT_LENGTH
|
from nucypher.config.constants import MAX_UPLOAD_CONTENT_LENGTH
|
||||||
from nucypher.crypto.keypairs import HostingKeypair, DecryptingKeypair
|
from nucypher.crypto.keypairs import DecryptingKeypair
|
||||||
from nucypher.crypto.kits import PolicyMessageKit
|
from nucypher.crypto.kits import PolicyMessageKit
|
||||||
from nucypher.crypto.powers import KeyPairBasedPower, PowerUpError
|
from nucypher.crypto.powers import KeyPairBasedPower, PowerUpError
|
||||||
from nucypher.crypto.signing import InvalidSignature
|
from nucypher.crypto.signing import InvalidSignature
|
||||||
|
@ -345,29 +345,3 @@ def _make_rest_app(datastore: Datastore, this_node, domain: str, log: Logger) ->
|
||||||
return Response(response=content, headers=headers)
|
return Response(response=content, headers=headers)
|
||||||
|
|
||||||
return rest_app
|
return rest_app
|
||||||
|
|
||||||
|
|
||||||
class TLSHostingPower(KeyPairBasedPower):
|
|
||||||
_keypair_class = HostingKeypair
|
|
||||||
provides = ("get_deployer",)
|
|
||||||
|
|
||||||
class NoHostingPower(PowerUpError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
not_found_error = NoHostingPower
|
|
||||||
|
|
||||||
def __init__(self,
|
|
||||||
host: str,
|
|
||||||
public_certificate=None,
|
|
||||||
public_certificate_filepath=None,
|
|
||||||
*args, **kwargs) -> None:
|
|
||||||
|
|
||||||
if public_certificate and public_certificate_filepath:
|
|
||||||
# TODO: Design decision here: if they do pass both, and they're identical, do we let that slide? NRN
|
|
||||||
raise ValueError("Pass either a public_certificate or a public_certificate_filepath, not both.")
|
|
||||||
|
|
||||||
if public_certificate:
|
|
||||||
kwargs['keypair'] = HostingKeypair(certificate=public_certificate, host=host)
|
|
||||||
elif public_certificate_filepath:
|
|
||||||
kwargs['keypair'] = HostingKeypair(certificate_filepath=public_certificate_filepath, host=host)
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ from flask import Flask
|
||||||
from nucypher.characters.lawful import Alice, Bob, Ursula
|
from nucypher.characters.lawful import Alice, Bob, Ursula
|
||||||
from nucypher.config.constants import TEMPORARY_DOMAIN
|
from nucypher.config.constants import TEMPORARY_DOMAIN
|
||||||
from nucypher.crypto.keystore import Keystore
|
from nucypher.crypto.keystore import Keystore
|
||||||
from nucypher.crypto.powers import DecryptingPower, DelegatingPower
|
from nucypher.crypto.powers import DecryptingPower, DelegatingPower, TLSHostingPower
|
||||||
from nucypher.crypto.umbral_adapter import SecretKey, Signer
|
from nucypher.crypto.umbral_adapter import SecretKey, Signer
|
||||||
from nucypher.datastore.datastore import Datastore
|
from nucypher.datastore.datastore import Datastore
|
||||||
from nucypher.network.server import TLSHostingPower, ProxyRESTServer
|
from nucypher.network.server import ProxyRESTServer
|
||||||
from nucypher.utilities.networking import LOOPBACK_ADDRESS
|
from nucypher.utilities.networking import LOOPBACK_ADDRESS
|
||||||
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
||||||
from tests.utils.matchers import IsType
|
from tests.utils.matchers import IsType
|
||||||
|
|
|
@ -40,13 +40,12 @@ from nucypher.crypto.keystore import (
|
||||||
_write_keystore,
|
_write_keystore,
|
||||||
_read_keystore
|
_read_keystore
|
||||||
)
|
)
|
||||||
from nucypher.crypto.powers import DecryptingPower, SigningPower, DelegatingPower
|
from nucypher.crypto.powers import DecryptingPower, SigningPower, DelegatingPower, TLSHostingPower
|
||||||
from nucypher.crypto.umbral_adapter import SecretKey
|
from nucypher.crypto.umbral_adapter import SecretKey
|
||||||
from nucypher.crypto.umbral_adapter import (
|
from nucypher.crypto.umbral_adapter import (
|
||||||
secret_key_factory_from_seed,
|
secret_key_factory_from_seed,
|
||||||
secret_key_factory_from_secret_key_factory
|
secret_key_factory_from_secret_key_factory
|
||||||
)
|
)
|
||||||
from nucypher.network.server import TLSHostingPower
|
|
||||||
from nucypher.utilities.networking import LOOPBACK_ADDRESS
|
from nucypher.utilities.networking import LOOPBACK_ADDRESS
|
||||||
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue