def __init__(self, *, address=None, mac=None, pincode=None, port=None): """Initialize a new object. Create key pair. Must be called with keyword arguments. """ self.address = address or util.get_local_address() self.mac = mac or util.generate_mac() self.pincode = pincode or util.generate_pincode() self.port = port or DEFAULT_PORT self.setup_id = util.generate_setup_id() self.config_version = DEFAULT_CONFIG_VERSION self.paired_clients = {} sk, vk = ed25519.create_keypair() self.private_key = sk self.public_key = vk
def setup_id(self): if not getattr(self, '_setup_id', None): self._setup_id = util.generate_setup_id() return self._setup_id
def test_generate_setup_id(): """Test generate_setup_id.""" assert len(util.generate_setup_id()) == 4