mirror of https://github.com/nucypher/nucypher.git
Import Vladimir's eth keys to the keychain.
parent
d92c6fe5c3
commit
a8516ec9ca
|
@ -19,7 +19,6 @@ from nucypher.characters.lawful import Ursula
|
|||
from nucypher.config.characters import UrsulaConfiguration
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_FILE_LOCATION, BASE_DIR
|
||||
from nucypher.config.node import DEFAULT_CONFIG_ROOT, NodeConfiguration
|
||||
from nucypher.config.utils import validate_nucypher_ini_config, collect_stored_nodes
|
||||
from nucypher.utilities.sandbox.blockchain import TesterBlockchain
|
||||
from nucypher.utilities.sandbox.ursula import UrsulaProcessProtocol
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from eth_tester.exceptions import ValidationError
|
||||
|
||||
from nucypher.characters.lawful import Ursula
|
||||
from nucypher.crypto.powers import CryptoPower
|
||||
from nucypher.utilities.sandbox.constants import TEST_URSULA_INSECURE_DEVELOPMENT_PASSWORD
|
||||
from nucypher.utilities.sandbox.middleware import EvilMiddleWare
|
||||
|
||||
|
||||
|
@ -10,21 +13,39 @@ class Vladimir(Ursula):
|
|||
|
||||
network_middleware = EvilMiddleWare()
|
||||
fraud_address = '0xbad022A87Df21E4c787C7B1effD5077014b8CC45'
|
||||
frad_key = 'a75d701cc4199f7646909d15f22e2e0ef6094b3e2aa47a188f35f47e8932a7b9'
|
||||
fraud_key = 'a75d701cc4199f7646909d15f22e2e0ef6094b3e2aa47a188f35f47e8932a7b9'
|
||||
|
||||
@classmethod
|
||||
def from_target_ursula(cls, target_ursula):
|
||||
"""
|
||||
Sometimes Vladimir seeks to attack or imitate
|
||||
|
||||
|
||||
a *specific* target Ursula.
|
||||
Sometimes Vladimir seeks to attack or imitate a *specific* target Ursula.
|
||||
"""
|
||||
|
||||
vladimir = cls(crypto_power=CryptoPower(power_ups=Ursula._default_crypto_powerups),
|
||||
rest_host=target_ursula.rest_information()[0].host,
|
||||
rest_port=target_ursula.rest_information()[0].port,
|
||||
checksum_address=cls.fraud_address,
|
||||
certificate=target_ursula.rest_server_certificate(),
|
||||
is_me=False)
|
||||
|
||||
vladimir._interface_signature_object = target_ursula._interface_signature_object # Asshole.
|
||||
|
||||
cls.attach_transacting_key(blockchain=target_ursula.blockchain)
|
||||
|
||||
return vladimir
|
||||
|
||||
@classmethod
|
||||
def attach_transacting_key(cls, blockchain):
|
||||
"""
|
||||
Upload Vladimir's ETH keys to the keychain via web3 / RPC.
|
||||
"""
|
||||
try:
|
||||
passphrase = TEST_URSULA_INSECURE_DEVELOPMENT_PASSWORD
|
||||
blockchain.interface.w3.personal.importRawKey(private_key=cls.fraud_key, passphrase=passphrase)
|
||||
except (ValidationError, ):
|
||||
# check if Vlad's key is already on the keyring...
|
||||
if cls.fraud_address in blockchain.interface.w3.personal.listAccounts:
|
||||
return True
|
||||
else:
|
||||
raise
|
||||
return True
|
||||
|
|
|
@ -65,12 +65,6 @@ def test_vladimir_cannot_verify_interface_with_ursulas_signing_key(blockchain_ur
|
|||
|
||||
# Vladimir imitates Ursula - copying her public keys and interface info, but inserting his ether address.
|
||||
vladimir = Vladimir.from_target_ursula(his_target)
|
||||
# Ursula(crypto_power=his_target._crypto_power,
|
||||
# rest_host=his_target.rest_information()[0].host,
|
||||
# rest_port=his_target.rest_information()[0].port,
|
||||
# checksum_address=Vladimir.ether_address,
|
||||
# interface_signature=his_target._interface_signature,
|
||||
# is_me=False)
|
||||
|
||||
# Vladimir can substantiate the stamp using his own ether address...
|
||||
vladimir.substantiate_stamp()
|
||||
|
@ -91,16 +85,10 @@ def test_vladimir_uses_his_own_signing_key(alice, blockchain_ursulas):
|
|||
using his own signing key, which he claims is Ursula's.
|
||||
"""
|
||||
his_target = list(blockchain_ursulas)[4]
|
||||
vladimir_ether_address = '0xE57bFE9F44b819898F47BF37E5AF72a0783e1141'
|
||||
|
||||
fraduluent_keys = CryptoPower(power_ups=Ursula._default_crypto_powerups)
|
||||
|
||||
vladimir = Ursula(crypto_power=fraduluent_keys,
|
||||
rest_host=his_target.rest_information()[0].host,
|
||||
rest_port=his_target.rest_information()[0].port,
|
||||
checksum_address=vladimir_ether_address,
|
||||
certificate=his_target.rest_server_certificate(),
|
||||
is_me=False)
|
||||
vladimir = Vladimir.from_target_ursula(target_ursula=his_target)
|
||||
|
||||
message = vladimir._signable_interface_info_message()
|
||||
signature = vladimir._crypto_power.power_ups(SigningPower).sign(message)
|
||||
|
|
Loading…
Reference in New Issue