class Invite {

  public static Invite fromCanonicalForm(String inviteCode) {
    String exceptionMessage = "Invite code should be of format host:port:publicKey.curveName~secretKey";

    List<String> parts = Splitter.on(':').splitToList(inviteCode);

    if (parts.size() != 3) {
      throw new MalformedInviteCodeException(exceptionMessage);
    }

    String host = parts.get(0);
    String portString = parts.get(1);
    int port = toPort(portString);

    List<String> keyAndSecret = Splitter.on('~').splitToList(parts.get(2));

    if (keyAndSecret.size() != 2) {
      throw new MalformedInviteCodeException(exceptionMessage);
    }

    String fullKey = keyAndSecret.get(0);
    List<String> splitKey = Splitter.on('.').splitToList(fullKey);

    if (splitKey.size() != 2) {
      throw new MalformedInviteCodeException(exceptionMessage);
    }
    String keyPart = splitKey.get(0);

    String secretKeyPart = keyAndSecret.get(1);

    Signature.Seed secretKey = toSecretKey(secretKeyPart);
    Ed25519PublicKeyIdentity identity = toPublicKey(keyPart);

    return new Invite(host, port, identity, secretKey);
  }

  public  Invite(String host, int port, Identity identity, Signature.Seed seedKey);

}