Beispiel #1
0
        public void CorrectPrivateKeyAndAccountFormat()
        {
            var account_id = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);
            var result     = Signatures.ValidateAccountId(account_id);

            Assert.IsTrue(result);
        }
Beispiel #2
0
        public void SignNeo()
        {
            var account_id = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);
            var result     = Signatures.GetSignature(PrivateKey1, message, account_id);

            Assert.IsNotNull(result);
        }
Beispiel #3
0
        public void SignMono()
        {
            var account_id = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);
            var result     = PortableSignatures.GetSignature(PrivateKey1, message);

            Assert.IsNotNull(result);
        }
Beispiel #4
0
 public LightWallet(SecureString privateKey, string networkId)
 {
     _securePrivateKey = privateKey;
     _networkId        = networkId;
     _accountId        = Signatures.GetAccountIdFromPrivateKey(new NetworkCredential("", _securePrivateKey).Password);
     _client           = new LyraJsonRPCClient(_networkId, (s) =>
                                               Task.FromResult(Signatures.GetSignature(new NetworkCredential("", _securePrivateKey).Password, s, _accountId)));
 }
        public void PrivateKeyFormat()
        {
            var private_key = "1234567890";
            var account_id  = Signatures.GetAccountIdFromPrivateKey(private_key);

            var crypto = new ECC_DHA_AES_Encryptor();
            var result = crypto.GetSharedSecret(private_key, account_id);
        }
Beispiel #6
0
        public void VerifySignatureNeo()
        {
            var account_id = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);
            var signature  = Signatures.GetSignature(PrivateKey1, message, account_id);

            var result = Signatures.VerifyAccountSignature(message, account_id, signature);

            Assert.IsTrue(result);
        }
Beispiel #7
0
        public void GetSharedSecret()
        {
            var AccountId2 = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();
            var result = crypto.GetSharedSecret(PrivateKey1, AccountId2);

            Assert.IsNotNull(result);
        }
Beispiel #8
0
        public TransitWallet(string privateKey, LyraRestClient client)
        {
            _uniqId = Guid.NewGuid().ToString();

            _privateKey = privateKey;
            _accountId  = Signatures.GetAccountIdFromPrivateKey(privateKey);

            _rpcClient = client;

            _signer = (hash) => Signatures.GetSignature(_privateKey, hash, _accountId);
        }
Beispiel #9
0
        public void VerifyMonoSignatureByNeo()
        {
            var account_id = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            Assert.AreEqual(account_id, PublicKey1);
            var signature = PortableSignatures.GetSignature(PrivateKey1, message);

            var result = Signatures.VerifyAccountSignature(message, account_id, signature);

            Assert.IsTrue(result);
        }
Beispiel #10
0
        public TransitWallet(string AccountId, string signingPrivateKey, LyraRestClient client)
        {
            _signingPrivateKey = signingPrivateKey;
            _signingAccountId  = Signatures.GetAccountIdFromPrivateKey(_signingPrivateKey);

            _accountId = AccountId;

            _rpcClient = client;

            _signer = (hash) => Task.FromResult(Signatures.GetSignature(_signingPrivateKey, hash, _signingAccountId));
        }
        public void GetSharedSecret()
        {
            var PrivateKey1 = "DQDP23xgHmLSsdm64qu1UsMteA5qDfgTiFRQRbjnfKstkg4LN";
            var AccountId1  = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var PrivateKey2 = "2CcBpc2vn8uXeiXp7sW15w3wFYCWt36VufrKuPBzqnxVQto64H";
            var AccountId2  = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();
            var result = crypto.GetSharedSecret(PrivateKey1, AccountId2);

            Assert.IsNotNull(result);
        }
Beispiel #12
0
        public void EncryptionDecryption()
        {
            var AccountId1 = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var AccountId2 = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            var salt = "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq";

            string encryptedMessage = crypto.Encrypt(PrivateKey1, AccountId2, salt, message);
            string decryptedMessage = crypto.Decrypt(PrivateKey2, AccountId1, salt, encryptedMessage);

            Assert.AreEqual <string>(message, decryptedMessage);
        }
        public void EncryptionDecryption()
        {
            var PrivateKey1 = "DQDP23xgHmLSsdm64qu1UsMteA5qDfgTiFRQRbjnfKstkg4LN";
            var AccountId1  = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var PrivateKey2 = "2CcBpc2vn8uXeiXp7sW15w3wFYCWt36VufrKuPBzqnxVQto64H";
            var AccountId2  = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            var message = "This is the test message";
            var salt    = "54CRv2pEjNj8c3UBPv4AxYmEKEojmVdAagTpgSjHieAq";

            string encryptedMessage = crypto.Encrypt(PrivateKey1, AccountId2, salt, message);
            string decryptedMessage = crypto.Decrypt(PrivateKey2, AccountId1, salt, encryptedMessage);

            Assert.AreEqual <string>(message, decryptedMessage);
        }
Beispiel #14
0
        public void GetSharedSecretOnBothKeyPairs()
        {
            var AccountId1 = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var AccountId2 = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            byte[] result1 = crypto.GetSharedSecret(PrivateKey1, AccountId2);
            byte[] result2 = crypto.GetSharedSecret(PrivateKey2, AccountId1);

            string str1 = Base58Encoding.Encode(result1);
            string str2 = Base58Encoding.Encode(result2);

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);

            Assert.AreEqual <string>(str1, str2);
        }
        public void GetSharedSecretOnBothKeyPairs()
        {
            var PrivateKey1 = "DQDP23xgHmLSsdm64qu1UsMteA5qDfgTiFRQRbjnfKstkg4LN";
            var AccountId1  = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            var PrivateKey2 = "2CcBpc2vn8uXeiXp7sW15w3wFYCWt36VufrKuPBzqnxVQto64H";
            var AccountId2  = Signatures.GetAccountIdFromPrivateKey(PrivateKey2);

            var crypto = new ECC_DHA_AES_Encryptor();

            byte[] result1 = crypto.GetSharedSecret(PrivateKey1, AccountId2);
            byte[] result2 = crypto.GetSharedSecret(PrivateKey2, AccountId1);

            string str1 = Base58Encoding.Encode(result1);
            string str2 = Base58Encoding.Encode(result2);

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);

            Assert.AreEqual <string>(str1, str2);
        }
Beispiel #16
0
        public async Task <ExchangeAccount> AddExchangeAccount(string assocaitedAccountId)
        {
            var findResult = await _exchangeAccounts.FindAsync(a => a.AssociatedToAccountId == assocaitedAccountId);

            var findAccount = await findResult.FirstOrDefaultAsync();

            if (findAccount != null)
            {
                return(findAccount);
            }

            var walletPrivateKey = Signatures.GenerateWallet().privateKey;
            var walletAccountId  = Signatures.GetAccountIdFromPrivateKey(walletPrivateKey);

            var account = new ExchangeAccount()
            {
                AssociatedToAccountId = assocaitedAccountId,
                AccountId             = walletAccountId,
                PrivateKey            = walletPrivateKey
            };
            await _exchangeAccounts.InsertOneAsync(account);

            return(account);
        }
Beispiel #17
0
        public void AccountIdByNeo()
        {
            var pubKey1 = Signatures.GetAccountIdFromPrivateKey(PrivateKey1);

            Assert.AreEqual(pubKey1, PublicKey1);
        }
        private SemaphoreSlim semaphore = new SemaphoreSlim(1);      // we need to run tests in serial

        public static TransitWallet Restore(string privateKey)
        {
            var accountId = Signatures.GetAccountIdFromPrivateKey(privateKey);

            return(new TransitWallet(accountId, privateKey, LyraRestClient.Create(TestConfig.networkId, "Windows", "UnitTest", "1.0")));
        }
Beispiel #19
0
 public void BadPrivateKeyFormat()
 {
     var private_key = "1234567890";
     var account_id  = Signatures.GetAccountIdFromPrivateKey(private_key);
 }