mirror of https://github.com/nucypher/nucypher.git
updates simple tdec example for use with alpha 5
parent
1dd541725f
commit
1c6d299837
|
@ -5,7 +5,10 @@ from nucypher_core.ferveo import DkgPublicKey
|
|||
|
||||
import nucypher
|
||||
from nucypher.blockchain.eth.agents import CoordinatorAgent
|
||||
from nucypher.blockchain.eth.registry import LocalContractRegistry
|
||||
from nucypher.blockchain.eth.registry import (
|
||||
InMemoryContractRegistry,
|
||||
LocalContractRegistry,
|
||||
)
|
||||
from nucypher.characters.lawful import Bob, Enrico, Ursula
|
||||
from nucypher.policy.conditions.lingo import ConditionLingo
|
||||
from nucypher.utilities.logging import GlobalLoggerSettings
|
||||
|
@ -18,11 +21,11 @@ LOG_LEVEL = 'info'
|
|||
GlobalLoggerSettings.set_log_level(log_level_name=LOG_LEVEL)
|
||||
GlobalLoggerSettings.start_console_logging()
|
||||
|
||||
provider_uri = os.environ['DEMO_L1_PROVIDER_URI']
|
||||
network = 'lynx'
|
||||
here = Path(nucypher.__file__).parent
|
||||
path = here / 'blockchain/eth/contract_registry/lynx/contract_registry.json'
|
||||
registry = LocalContractRegistry(filepath=path)
|
||||
staking_provider_uri = os.environ["DEMO_L1_PROVIDER_URI"]
|
||||
network = "lynx"
|
||||
|
||||
coordinator_provider_uri = os.environ["DEMO_L2_PROVIDER_URI"]
|
||||
coordinator_network = "mumbai"
|
||||
|
||||
###############
|
||||
# Enrico
|
||||
|
@ -30,10 +33,15 @@ registry = LocalContractRegistry(filepath=path)
|
|||
|
||||
print('--------- Threshold Encryption ---------')
|
||||
|
||||
coordinator_agent = CoordinatorAgent(eth_provider_uri=provider_uri, registry=registry)
|
||||
ritual_id = 0 # got this from a side channel
|
||||
coordinator_agent = CoordinatorAgent(
|
||||
eth_provider_uri=coordinator_provider_uri,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(
|
||||
network=coordinator_network
|
||||
),
|
||||
)
|
||||
ritual_id = 3 # got this from a side channel
|
||||
ritual = coordinator_agent.get_ritual(ritual_id)
|
||||
enrico = Enrico(encrypting_key=DkgPublicKey.from_bytes(ritual.public_key))
|
||||
enrico = Enrico(encrypting_key=DkgPublicKey.from_bytes(bytes(ritual.public_key)))
|
||||
|
||||
print(f'Fetched DKG public key {bytes(enrico.policy_pubkey).hex()} '
|
||||
f'for ritual #{ritual_id} '
|
||||
|
@ -60,10 +68,11 @@ print(f'Encrypted message: {bytes(ciphertext).hex()}')
|
|||
print('--------- Threshold Decryption ---------')
|
||||
|
||||
bob = Bob(
|
||||
eth_provider_uri=provider_uri,
|
||||
eth_provider_uri=staking_provider_uri,
|
||||
domain=network,
|
||||
registry=registry,
|
||||
known_nodes=[Ursula.from_teacher_uri('https://lynx.nucypher.network:9151', min_stake=0)]
|
||||
coordinator_provider_uri=coordinator_provider_uri,
|
||||
coordinator_network=coordinator_network,
|
||||
registry=InMemoryContractRegistry.from_latest_publication(network=network),
|
||||
)
|
||||
|
||||
bob.start_learning_loop(now=True)
|
||||
|
|
Loading…
Reference in New Issue