Ejemplo n.º 1
0
        public void GenerateCurveLockKeyPairNoMailTest()
        {
            const string email    = null;
            const string password = "******";

            KeyGenerator.GenerateCurveLockKeyPair(email, password);
        }
Ejemplo n.º 2
0
        public void GenerateCurveLockKeyPairNoPasswordTest()
        {
            const string email    = "*****@*****.**";
            const string password = null;

            KeyGenerator.GenerateCurveLockKeyPair(email, password);
        }
Ejemplo n.º 3
0
        public void GenerateCurveLockKeyPairTest()
        {
            const string expected = "MrDDGk7GYEypr93LMgJn4Av3c98fWamRKvAKbjrTEvjtz5kRxj";
            const string email    = "*****@*****.**";
            const string password = "******";

            Console.WriteLine("--- Generate CurveLock KeyPair start ---");
            var zx = new Zxcvbn.Zxcvbn();

            Console.WriteLine(" - E-Mail (utf8): " + email + " [" + email.Length + "]");
            Console.WriteLine(" - E-Mail Entropy (~): " + zx.EvaluatePassword(email).Entropy);
            Console.WriteLine(" - Password (utf8): " + password + " [" + password.Length + "]");
            Console.WriteLine(" - Password Entropy (~): " + zx.EvaluatePassword(password).Entropy);
            var keyPair = KeyGenerator.GenerateCurveLockKeyPair(email, password);

            Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" +
                              keyPair.PrivateKey.Length + "]");
            Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" +
                              keyPair.PublicKey.Length + "]");
            var encodedPublicKey = KeyGenerator.EncodeCurveLockPublicKey(keyPair.PublicKey);

            Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" +
                              encodedPublicKey.Length + "]");
            Console.WriteLine("--- Generate CurveLock KeyPair end ---");
            Assert.AreEqual(expected, encodedPublicKey);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Caluclate a keypair.
        /// </summary>
        public async void CalculateKeyPair()
        {
            var result = false;

            try
            {
                if (KeyFormatBytejailChecked)
                {
                    IsCalculating = true;
                    await
                    Task.Run(() => { KeyPair = KeyGenerator.GenerateBytejailKeyPair(InputOne, InputTwo); })
                    .ConfigureAwait(false);

                    result = true;
                }
                else if (KeyFormatCurveLockChecked)
                {
                    //TODO: validate input (mail) before calculate
                    IsCalculating = true;
                    await
                    Task.Run(() => { KeyPair = KeyGenerator.GenerateCurveLockKeyPair(InputOne, InputTwo); })
                    .ConfigureAwait(false);

                    result = true;
                }
                else if (KeyFormatMiniLockChecked)
                {
                    //TODO: validate input (mail) before calculate
                    IsCalculating = true;
                    await
                    Task.Run(() => { KeyPair = KeyGenerator.GenerateMiniLockKeyPair(InputOne, InputTwo); })
                    .ConfigureAwait(false);

                    result = true;
                }
            }
            catch (ArgumentNullException)
            {
                Environment.Exit(0);
            }
            IsCalculating             = false;
            InputOne                  = string.Empty;
            InputTwo                  = string.Empty;
            KeyFormatCurveLockChecked = false;
            KeyFormatMiniLockChecked  = false;
            KeyFormatBytejailChecked  = true;
            TryClose(result);
        }