How to use the openpgp.verify function in openpgp

To help you get started, we’ve selected a few openpgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / openpgp / openpgp-tests.ts View on Github external
detached: true
    }).then(s => s.signature/* as openpgp.signature.Signature*/);
    openpgp.sign({
        message: null,
        privateKeys: [],
        armor: false,
        detached: false,
    }).then(s => s.message/* as openpgp.message.Message*/);

    const verifyOptions: openpgp.VerifyOptions = {
        message,
        signature,
        publicKeys: publicKey.keys
    };

    const verified = await openpgp.verify(verifyOptions);

    return verified.signatures[0].valid;
})();
github transmute-industries / transmute / packages / transmute-did / src / lib / cryptoSuites / openpgpExtensions / cryptoHelpers / index.js View on Github external
return new Promise((resolve) => {
    openpgp.verify(options).then((verified) => {
      const validity = verified.signatures[0].valid; // true
      resolve(validity);
    });
  });
};
github transmute-industries / transmute / packages / transmute-did / src / lib / cryptoSuites / openpgpExtensions / cryptoHelpers / index.js View on Github external
const verifyDetached = async (message, detachedSig, publicKey) => {
  const options = {
    message: openpgp.cleartext.fromText(message), // CleartextMessage or Message object
    signature: await openpgp.signature.readArmored(detachedSig), // parse detached signature
    publicKeys: (await openpgp.key.readArmored(publicKey)).keys, // for verification
  };

  const verified = await openpgp.verify(options);
  const validity = verified.signatures[0].valid; // true
  return validity;
};
github redhat-developer-tooling / developer-platform-install / browser / services / openpgp.js View on Github external
return Promise.resolve().then(()=>{
    let options = {
      message: openpgp.cleartext.readArmored(armoredText), // parse armored message
      publicKeys: openpgp.key.readArmored(keyText).keys   // for verification
    };
    return openpgp.verify(options).then((verified)=>{
      return {options, verified};
    });
  }).catch((error)=>{
    return {
github RedpointGames / pkgsign / dist / lib / pgpVerifier.js View on Github external
const attemptVerify = (rawPublicKeys) => __awaiter(this, void 0, void 0, function* () {
                try {
                    const publicKeys = openpgp.key.readArmored(rawPublicKeys).keys;
                    const verifyOptions = {
                        message: openpgp.message.fromText(deterministicSignature),
                        signature: openpgp.signature.readArmored(signature),
                        publicKeys: publicKeys
                    };
                    const verifiedMessage = yield openpgp.verify(verifyOptions);
                    return verifiedMessage.signatures.length >= 1;
                }
                catch (e) {
                    return false;
                }
            });
            let urlHashObj = crypto.createHash('sha512');
github isomorphic-git / isomorphic-git / src / models / PGP.js View on Github external
static async verify (email, msg) {
    const publicKeys = locallookup(email)
    const verified = await openpgp.verify({
      publicKeys: publicKeys,
      message: openpgp.cleartext.readArmored(msg)
    })
    let signature = verified.signatures.map(getFullSignature)
    signature = signature.filter(x => x.email === email)
    if (signature.length !== 1) {
      return false
    } else {
      return signature[0].valid
    }
  }
github RedpointGames / pkgsign / src / lib / identity / keybase.ts View on Github external
const attemptVerify = async (rawPublicKeys: string) => {
      try {
        const publicKeys = (await openpgp.key.readArmored(rawPublicKeys)).keys;
        const verifyOptions = {
          message: openpgp.message.fromText(deterministicString),
          signature: await openpgp.signature.readArmored(signature),
          publicKeys: publicKeys
        };
        const verifiedMessage = await openpgp.verify(verifyOptions);
        return verifiedMessage.signatures.length >= 1;
      } catch (e) {
        return false;
      }
    };
github ProtonMail / WebClient / src / libraries / pmcrypto.js View on Github external
return reject(new Error('Missing signed message'));
            }

            if (pubKeys === undefined || pubKeys.length < 1) {
                return reject(new Error('Missing public keys'));
            }

            const message = openpgp.cleartext.readArmored(signedMessage.trim());
            if (message instanceof Error) return reject(message);

            const options = {
                message: message,
                publicKeys: pubKeys,
            };

            openpgp.verify(options).then((signedMsg) => {
                resolve(signedMsg);
            }).catch(function(err) {
                reject('Message verification failed');
            });
        });
    }
github tasn / webext-signed-pages / src / background.js View on Github external
const content = new Minimize({ spare:true, conditionals: true, empty: true, quotes: true }).parse(rawContent)
    .replace(/^\s*]*>/i, '');

  const shouldCheck = getPubkey(patterns, url);

  if (shouldCheck) {
    try {
      const pubkey = patterns[shouldCheck];

      const options = {
        message: openpgp.message.fromBinary(openpgp.util.str2Uint8Array(content)),
        signature: openpgp.signature.readArmored(signature),
        publicKeys: openpgp.key.readArmored(pubkey).keys,
      };

      openpgp.verify(options).then((verified) => {
        const signatureData = (verified.signatures[0].valid) ? goodSignature : badSignature;
        updateBrowserAction(signatureData, tabId);
        statusCache[url] = signatureData;
      });
    } catch (e) {
      updateBrowserAction(badSignature, tabId);
      statusCache[url] = badSignature;
    }
  } else {
    updateBrowserAction(neutralSignature, tabId);
  }
}
github RedpointGames / pkgsign / dist / lib / keybaseVerifier.js View on Github external
const attemptVerify = (rawPublicKeys) => __awaiter(this, void 0, void 0, function* () {
                try {
                    const publicKeys = openpgp.key.readArmored(rawPublicKeys).keys;
                    const verifyOptions = {
                        message: openpgp.message.fromText(deterministicSignature),
                        signature: openpgp.signature.readArmored(signature),
                        publicKeys: publicKeys
                    };
                    const verifiedMessage = yield openpgp.verify(verifyOptions);
                    return verifiedMessage.signatures.length >= 1;
                }
                catch (e) {
                    return false;
                }
            });
            let rawPublicKeys = yield this.trustStore.getOrFetchCachedPublicKeys('keybase.io.' + identity.keybaseUser, fetchPub);