Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const testVerify = function (sig, msg, expected) {
// manually construct a key based on the saved privKeyHex and pubKeyHex
const f = new ECDSA({curve: 'secp256r1'});
f.setPrivateKeyHex(TEST_KEY_PRIVATE);
f.setPublicKeyHex(TEST_KEY_PUBLIC);
f.isPrivate = true;
f.isPublic = false;
t.equal(cryptoUtils.verify(new ecdsaKey(f), sig, msg), expected,
'CryptoSuite_ECDSA_AES function tests: verify() method');
};async importIdentity(client, label, identity) {
// check the identity type
const cryptoContent = {
signedCertPEM: identity.certificate
};
const publicKey = KEYUTIL.getKey(identity.certificate);
const ecdsakey = new ecdsaKey(publicKey);
cryptoContent.privateKeyObj = await this.cryptoSuite.getKey(Buffer.from(ecdsakey.getSKI(), 'hex'));
await client.createUser({
username: label,
mspid: identity.mspId,
cryptoContent: cryptoContent
});
}'CCqGSM49AwEHA0IABLoGEWBb+rQ/OuTBPlGVZO3jVWBcuC4+/pAq8axbtKorpORw' +
'J/GxahKPLr+vVLPNMyeLcnyJBGgneug+ajE8srijfzB9MA4GA1UdDwEB/wQEAwIF' +
'oDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAd' +
'BgNVHQ4EFgQU9BUt7QfgDXx9g6zpzCyJGxXsNM0wHwYDVR0jBBgwFoAUF2dCPaqe' +
'gj/ExR2fW8OZ0bWcSBAwCgYIKoZIzj0EAwIDSAAwRQIgcWQbMzluyZsmvQCvGzPg' +
'f5B7ECxK0kdmXPXIEBiizYACIQD2x39Q4oVwO5uL6m3AVNI98C2LZWa0g2iea8wk' +
'BAHpeA==' +
'-----END CERTIFICATE-----';
const dbname = 'test_keystore';
const dbclient = nano('http://localhost:5985');
const f1 = KEYUTIL.getKey(TEST_KEY_PRIVATE_PEM);
const testPrivKey = new ecdsaKey(f1);
const f2 = KEYUTIL.getKey(TEST_KEY_PRIVATE_CERT_PEM);
const testPubKey = new ecdsaKey(f2);
test('\n\n** CryptoKeyStore tests **\n\n', (t) => {
testutil.resetDefaults();
const keystorePath = path.join(testutil.getTempDir(), 'crypto-key-store');
const store = CKS({path: keystorePath});
return store.initialize().then(() => {
store.putKey(testPrivKey).then(() => {
t.pass('Successfully saved private key in store');
t.equal(fs.existsSync(path.join(keystorePath, testPrivKey.getSKI() + '-priv')), true,
'Check that the private key has been saved with the proper -priv index');
return store.getKey(testPrivKey.getSKI());
}).then((recoveredKey) => {'BgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMTcwMTAzMDEyNDAw' +
'WhcNMTgwMTAzMDEyNDAwWjAQMQ4wDAYDVQQDEwVhZG1pbjBZMBMGByqGSM49AgEG' +
'CCqGSM49AwEHA0IABLoGEWBb+rQ/OuTBPlGVZO3jVWBcuC4+/pAq8axbtKorpORw' +
'J/GxahKPLr+vVLPNMyeLcnyJBGgneug+ajE8srijfzB9MA4GA1UdDwEB/wQEAwIF' +
'oDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAd' +
'BgNVHQ4EFgQU9BUt7QfgDXx9g6zpzCyJGxXsNM0wHwYDVR0jBBgwFoAUF2dCPaqe' +
'gj/ExR2fW8OZ0bWcSBAwCgYIKoZIzj0EAwIDSAAwRQIgcWQbMzluyZsmvQCvGzPg' +
'f5B7ECxK0kdmXPXIEBiizYACIQD2x39Q4oVwO5uL6m3AVNI98C2LZWa0g2iea8wk' +
'BAHpeA==' +
'-----END CERTIFICATE-----';
const dbname = 'test_keystore';
const dbclient = nano('http://localhost:5985');
const f1 = KEYUTIL.getKey(TEST_KEY_PRIVATE_PEM);
const testPrivKey = new ecdsaKey(f1);
const f2 = KEYUTIL.getKey(TEST_KEY_PRIVATE_CERT_PEM);
const testPubKey = new ecdsaKey(f2);
test('\n\n** CryptoKeyStore tests **\n\n', (t) => {
testutil.resetDefaults();
const keystorePath = path.join(testutil.getTempDir(), 'crypto-key-store');
const store = CKS({path: keystorePath});
return store.initialize().then(() => {
store.putKey(testPrivKey).then(() => {
t.pass('Successfully saved private key in store');
t.equal(fs.existsSync(path.join(keystorePath, testPrivKey.getSKI() + '-priv')), true,
'Check that the private key has been saved with the proper -priv index');