Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1001858 // getAuthorOfSignedJava

JavaX fragment (include)

sbool getAuthorOfSignedJava_debug;

static S getAuthorOfSignedJava(S signed) {
  try {
    L<S> lines = toLines(signed);
    S authorLine = lines.get(lines.size()-2);
    S sigLine = lines.get(lines.size()-1);
    S text = fromLines(lines.subList(0, lines.size()-1));
    S author = dropPrefixMandatory("// -", authorLine);
    if (!isComputerID(author)) fail("Not a computer ID: " + author);
    S publicKey = getPublicKeyOfComputer(author);
    if (publicKey == null)
      fail("Computer " + author + " has to publish a public key.");
    S sig = dropPrefixMandatory("// sig: ", sigLine);
    if (PKI.verifySignature(PKI.publicKeyFromString(publicKey), PKI.signatureFromString(sig), toUtf8(text)))
      ret author;
    else
      ret null;
  } catch (RuntimeException e) {
    ret null;
  }
}

Author comment

Began life as a copy of #1001567

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001858
Snippet name: getAuthorOfSignedJava
Eternal ID of this version: #1001858/2
Text MD5: e684873e15f96c99f10790976f95b22e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-03 18:18:39
Source code size: 819 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 468 / 728
Version history: 1 change(s)
Referenced in: [show references]