static S getAuthorOfSignedText(S signed) { try { L lines = toLines(signed); S authorLine = nextToLast(lines); S sigLine = last(lines); S text = fromLines(dropLast(lines)); //print("Verifying text: " + l(text) + " - " + quote(text)); if (!startsWith(authorLine, "-")) null; S author = dropPrefix("-", authorLine); author = beforeComma(author); // drop date etc. if (!isComputerID(author)) fail("Not a computer ID: " + author); //print("Possible author: " + author); S publicKey = getPublicKeyOfComputer(author); if (publicKey == null) fail("Computer " + author + " has to publish a public key."); if (!startsWith(sigLine, "sig: ")) null; S sig = dropPrefix("sig: ", sigLine); if (!PKI.verifySignature(PKI.publicKeyFromString(publicKey), PKI.signatureFromString(sig), toUtf8(text))) { print("Signature doesn't verify"); null; } ret author; } catch (RuntimeException e) { ret null; } }