How to use the fabric-common/lib/impl/ecdsa/key.js function in fabric-common

To help you get started, we’ve selected a few fabric-common 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 hyperledger / fabric-sdk-node / test / unit / cryptosuite-ecdsa-aes.js View on Github external
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');
			};
github hyperledger / fabric-sdk-node / fabric-network / lib / impl / wallet / hsmwalletmixin.js View on Github external
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
		});

	}
github hyperledger / fabric-sdk-node / test / unit / crypto-key-store.js View on Github external
'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) => {
github hyperledger / fabric-sdk-node / test / unit / crypto-key-store.js View on Github external
'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');