def mixnet_url_process(mixnet_url): catalog_url, endpoint_id = split_mixnet_url(mixnet_url) cfg.set_value("CATALOG_URL", catalog_url) client.register_catalog_url(catalog_url) print endpoint_id endpoint = client.endpoint_info(endpoint_id) if endpoint["status"] != "OPEN": abort("Endpoint is not open.") if endpoint["endpoint_type"] != "SPHINXMIX_GATEWAY": abort("Not a SPHINXMIX_GATEWAY.") peer_id = endpoint["peer_id"] cfg.set_value("PEER_ID", peer_id) peer = client.peer_info(peer_id) assert peer["crypto_backend"] == TYPE backend = common.BACKENDS[TYPE] client.register_backend(backend) cfg.set_value("CRYPTO_BACKEND", backend) crypto_params = canonical.from_unicode_canonical(peer["crypto_params"]) cfg.set_value("CRYPTO_PARAMS", crypto_params) description = {"gateway": endpoint, "mixnet_peer": peer} cfg.set_value("MIXNET_DESCRIPTION", description)
def handle_endpoints_wizard(role): while True: cycle = on("CYCLE", lambda: 1) peer_id = cfg.get("PEER_ID") combined_peer_id = cfg.get("COMBINED_PEER_ID") if role == "create": endpoints = create_endpoint_wizard(cycle, combined_peer_id) elif role == "join": endpoints = join_endpoint_wizard(cycle) endpoint_ids = [e["endpoint_id"] for e in endpoints] remaining = endpoint_ids while remaining: ui.inform("Still need to handle endpoints %s." % remaining) remaining = operate(remaining, peer_id, combined_peer_id, role) time.sleep(3) get_restart_response(role) ui.inform("Starting a new cycle...") cfg.set_value("CYCLE", cycle + 1)
def create_next_negotiation_id(): value = new_negotiation_id() cfg.set_value("NEXT_NEGOTIATION_ID", value)
def set_next_negotiation_id(value): cfg.set_value("NEXT_NEGOTIATION_ID", value)
def split_invitation(invitation): parts = invitation.split(INV_SEP) cfg.set_value("JOIN_NEGOTIATION_ID", parts[0]) cfg.set_value("JOIN_INVITATION_ID", parts[1]) return parts
def register_crypto_backend(crypto_backend): cfg.set_value("CRYPTO_BACKEND", crypto_backend) client.register_backend(crypto_backend)
def register_peer_with_owners(combined_peer_id): cfg.set_value("COMBINED_PEER_ID", combined_peer_id) peer = client.peer_info(combined_peer_id) client.peer_import(combined_peer_id) for owner in peer["owners"]: client.peer_import(owner["owner_key_id"])