internal string SignSGAMessageWithCode(int[] SecretSalt, int[] SecretPW, string sgaMessage, string DisplayCode) { 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.GetSGATokenForSignin(address, signature, DisplayCode); } catch { return "4"; } }
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", "" }; } }