Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((dsID) => {
t.equal(dsID._certificate, TEST_CERT_PEM, 'Identity class function tests: deserialized certificate');
t.equal(dsID._publicKey.isPrivate(), false, 'Identity class function tests: deserialized public key');
t.equal(dsID._publicKey._key.pubKeyHex, '0452a75e1ee105da7ab3d389fda69d8a04f5cf65b305b49cec7cdbdeb91a585cf87bef5a96aa9683d96bbabfe60d8cc6f5db9d0bc8c58d56bb28887ed81c6005ac', 'Identity class function tests: deserialized public key ecparam check');
// manually construct a key based on the saved privKeyHex and pubKeyHex
const f = KEYUTIL.getKey(TEST_KEY_PRIVATE_PEM);
const testKey = new ecdsaKey(f);
pubKey = testKey.getPublicKey();
const signer = new Signer(cryptoUtils, testKey);
t.equal(signer.getPublicKey().isPrivate(), false, 'Test Signer class getPublicKey() method');
const signingID = new SigningIdentity(TEST_KEY_PRIVATE_CERT_PEM, pubKey, mspImpl.getId(), cryptoUtils, signer);
t.throws(
() => {
signingID.sign(TEST_MSG, {hashFunction: 'not_a_function'});
},
/The "hashFunction" field must be a function/,
'Test invalid hashFunction parameter for the sign() method'
);
const sig = signingID.sign(TEST_MSG);
t.equal(cryptoUtils.verify(pubKey, sig, TEST_MSG), true, 'Test SigningIdentity sign() method');
t.equal(signingID.verify(TEST_MSG, sig), true, 'Test Identity verify() method');
t.end();
}).catch((err) => {
t.fail(err.stack ? err.stack : err);
() => {
new SigningIdentity('cert');
},
/Missing required parameter "publicKey"/,
() => {
new SigningIdentity('cert', 'pubKey', 'mspId', 'cryptoSuite');
},
/Missing required parameter "signer"/,
() => {
new SigningIdentity('cert', 'pubKey');
},
/Missing required parameter "mspId"/,