Ejemplo n.º 1
0
        internal string SignSGAMessage(int[] SecretSalt, int[] SecretPW, string sgaMessage)
        {
            try
            {
                ExtKey masterKey = GetExtKey(SecretSalt, SecretPW);

                ExtKey masterKeyD = masterKey.Derive(GetCurrencyIndex("btc"), hardened: true);
                ExtKey key = masterKeyD.Derive((uint)0);
                byte[] keybytes = key.PrivateKey.ToBytes();
                Key pkey = new Key(keybytes, -1, false);
                BitcoinSecret bitcoinSecret = new BitcoinSecret(pkey, Network.Main);
                var address = bitcoinSecret.PubKey.GetAddress(GetBLKNetworkAlt("btc")).ToString();
                var signature = bitcoinSecret.PrivateKey.SignMessage(sgaMessage);
                Sclear.EraseBytes(keybytes);

                masterKeyD = null;
                key = null;
                pkey = null;
                NWS WS = new NWS();
                return WS.GetSGAToken(address, signature);

            }
            catch
            {

                return "4";
            }
        }
Ejemplo n.º 2
0
        internal string[] SignSGAMessageOut(int[] SecretSalt, int[] SecretPW, string sgaMessage)
        {
            try
            {
                ExtKey masterKey = GetExtKey(SecretSalt, SecretPW);

                ExtKey masterKeyD = masterKey.Derive(GetCurrencyIndex("btc"), hardened: true);
                ExtKey key = masterKeyD.Derive((uint)0);
                byte[] keybytes = key.PrivateKey.ToBytes();

                Key pkey = new Key(keybytes, -1, false);
                BitcoinSecret bitcoinSecret = new BitcoinSecret(pkey, Network.Main);
                var address = bitcoinSecret.PubKey.GetAddress(GetBLKNetworkAlt("btc")).ToString();
                var signature = bitcoinSecret.PrivateKey.SignMessage(sgaMessage);
                Sclear.EraseBytes(keybytes);

                masterKeyD = null;

                key = null;
                pkey = null;
                NWS WS = new NWS();
                List\\ lnoxAddresses = new List\\();
                string adrlist = JsonConvert.SerializeObject(lnoxAddresses);
                string tkmsg = WS.GetSGAToken(address, signature);
                if (tkmsg.Length \                {
                    return new string[2] { tkmsg, adrlist };
                }

                var objaddrListindexes = WS.GetAddressIndexes(tkmsg);
                if (objaddrListindexes != null)
                {
                    lnoxAddresses = GetReviewIndexes(objaddrListindexes, masterKey);
                    adrlist = JsonConvert.SerializeObject(lnoxAddresses);
                }
                else
                {
                    tkmsg = "1";
                }
                return new string[2] { tkmsg, adrlist };
            }
            catch
            {
                return new string[2] { "4", "" };
            }
        }