Пример #1
0
        public void PrivateKey_Can_Be_Created_With_Valid_Input()
        {
            var privateKeyBytes = GenerateRandomByteArray(_wrapper.PrivateKeyLength);
            var privateKey      = _wrapper.GetPrivateKeyFromBytes(privateKeyBytes);

            privateKey.Should().NotBe(null);
        }
Пример #2
0
        public IPrivateKey KeyStoreDecrypt(KeyRegistryTypes keyIdentifier)
        {
            var json = GetJsonFromKeyStore(keyIdentifier);

            if (string.IsNullOrEmpty(json))
            {
                _logger.Error("No keystore exists for the given key");
                return(null);
            }

            var         keyBytes   = KeyStoreDecrypt(_defaultNodePassword, json);
            IPrivateKey privateKey = null;

            try
            {
                privateKey = _cryptoContext.GetPrivateKeyFromBytes(keyBytes);
            }
            catch (ArgumentException)
            {
                _logger.Error("Keystore did not contain a valid key");
            }

            return(privateKey);
        }