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

16
LINES

< > BotCompany Repo | #1004861 // locallyVerifyUserStatement

JavaX fragment (include)

static bool locallyVerifyUserStatement(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);
    S cid = trim(dropSuffix("[user]", author));
    if (!isComputerID(cid)) fail("Not a computer ID: " + cid);
    byte[] publicKey = PKI.userPublicKey();
    S sig = dropPrefixMandatory("sig: ", sigLine);
    ret PKI.verifySignature(publicKey, PKI.signatureFromString(sig), toUtf8(text));
  } catch (RuntimeException e) {
    ret false;
  }
}

Author comment

Began life as a copy of #1001567

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004861
Snippet name: locallyVerifyUserStatement
Eternal ID of this version: #1004861/1
Text MD5: 77dba25c1bff4808af0bb91b27267508
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-06 19:20:53
Source code size: 653 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 428 / 464
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)