Esempio n. 1
0
        public void GenerateKeys()
        {
            WriteLine("password key:");
            var privateKey = Secp256K1Manager.GenerateRandomKey();
            var privateWif = "P" + Base58.EncodePrivateWif(privateKey);

            WriteLine(privateWif);
            WriteLine(Hex.ToString(privateKey));

            var publicKey       = Secp256K1Manager.GetPublicKey(privateKey, true);
            var encodePublicWif = Base58.EncodePublicWif(publicKey, "STM");

            WriteLine(encodePublicWif);
            WriteLine(Hex.ToString(publicKey));

            var name = "userlogin";

            string[] roles = { "posting", "active", "owner", "memo" };

            foreach (var role in roles)
            {
                WriteLine(role);
                var subWif = Base58.GetSubWif(name, privateWif, role);
                WriteLine(subWif);
                var pk = Base58.DecodePrivateWif(subWif);
                WriteLine(Hex.ToString(pk));
                var subPublicKey = Secp256K1Manager.GetPublicKey(pk, true);
                var publicWif    = Base58.EncodePublicWif(subPublicKey, "STM");
                WriteLine(publicWif);
                WriteLine(Hex.ToString(subPublicKey));
            }
        }