/// <summary> /// Sets the various text to ask for the next number /// </summary> private void SetWordText() { int[] randomNums = dynamicDataCache.GetData("confirmation numbers"); HopeInputField inputField = wordInputField.GetComponent <HopeInputField>(); inputField.SetPlaceholderText("Word #" + randomNums[wordIndex]); inputField.Text = string.Empty; }
//[ReflectionProtect] private void GetConfirmationWords() { string[] correctWords; int[] numbers = dynamicDataCache.GetData("confirmation numbers"); List <int> randomIntList = numbers.ToList(); List <string> words = WalletUtils.GetMnemonicWords((string)dynamicDataCache.GetData("mnemonic")).ToList(); correctWords = words.Where(word => numbers.Contains(words.IndexOf(word) + 1)) .OrderBy(word => randomIntList.IndexOf(words.IndexOf(word) + 1)) .ToArray(); dynamicDataCache.SetData("confirmation words", correctWords); }
/// <summary> /// Called when the correct password is entered. /// </summary> /// <param name="password"> The correct password. </param> private void CorrectPassword(byte[] password) { if (dynamicDataCache.GetData("pass") != null && dynamicDataCache.GetData("pass") is ProtectedString) { ((ProtectedString)dynamicDataCache.GetData("pass")).SetValue(password); } else { dynamicDataCache.SetData("pass", new ProtectedString(password)); } SecurePlayerPrefs.SetInt(WalletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT, 1); userWalletManager.UnlockWallet(); }
/// <summary> /// Verifies a password. /// </summary> /// <param name="password"> The password to verify. </param> /// <returns> The current instance of WalletPasswordVerification. </returns> public WalletPasswordVerification VerifyPassword(byte[] password) { var saltedHash = hopeWalletInfoManager.GetWalletInfo((int)dynamicDataCache.GetData("walletnum")).EncryptedWalletData.PasswordHash; var pbkdf2 = new PBKDF2PasswordHashing(new Blake2b_512_Engine()); VerifyingPassword = true; onPasswordCorrect = null; onPasswordIncorrect = null; Observable.WhenAll(Observable.Start(() => password == null || password.Length == 0 ? false : pbkdf2.VerifyPassword(password, saltedHash))) .ObserveOnMainThread() .Subscribe(correctPass => { VerifyingPassword = false; if (!correctPass[0]) { PasswordIncorrect(); } else { PasswordCorrect(password); } }); return(this); }
/// <summary> /// Checks if data already exists in the DynamicDataCache. /// If the data is equal to the mnemonic entered in the input fields, display the ConfirmMnemonicMenu. /// </summary> /// <returns> True if the mnemonic was unique and the wallet can be directly imported. </returns> private bool CheckCreatedMnemonic() { Wallet wallet = null; string newMnemonic = string.Join(" ", wordFields.Select(field => field.Text)).Trim(); byte[] seed = (byte[])dynamicDataCache.GetData("seed"); try { wallet = new Wallet(newMnemonic, null, WalletUtils.DetermineCorrectPath(newMnemonic)); nextButton.GetComponent <InteractableButton>().OnCustomPointerExit(); } catch { nextButton.interactable = false; importMneomonicMenuAnimator.AnimateIcon(importMneomonicMenuAnimator.nextButtonErrorIcon); importMneomonicMenuAnimator.AnimateIcon(importMneomonicMenuAnimator.nextButtonErrorMessage); importMneomonicMenuAnimator.OpeningWallet = false; return(false); } if (seed?.SequenceEqual(wallet.Seed) == true) { uiManager.OpenMenu <ConfirmMnemonicMenu>(); return(false); } else { SetWalletInfo(wallet); return(true); } }
/// <summary> /// The password is correct and the user is brought back to the OpenWalletMenu /// </summary> /// <param name="password"> The password string</param> private void CorrectPassword(byte[] password) { (dynamicDataCache.GetData("pass") as ProtectedString)?.SetValue(password); SecurePlayerPrefs.SetInt(walletName + PlayerPrefConstants.SETTING_CURRENT_LOGIN_ATTEMPT, 1); OnPasswordEnteredCorrect?.Invoke(); uiManager.CloseMenu(); }
public void Load(string[][] addresses, Action onWalletLoaded) { SetupLoadActions(onWalletLoaded); addresses[0] = new string[50]; addresses[1] = new string[50]; this.addresses = addresses; (dynamicDataCache.GetData("pass") as ProtectedString)?.CreateDisposableData().OnSuccess(disposableData => LoadWallet((byte[])disposableData.ByteValue.Clone())); }
private void SavePasswordButtonClicked() { settingsPopupAnimator.ShowLoadingIcon(saveButton.gameObject, loadingIcon, true); var promise = (dynamicDataCache.GetData("pass") as ProtectedString)?.CreateDisposableData(); promise.OnSuccess(disposableData => walletDecryptor.DecryptWallet(walletInfo, (byte[])disposableData.ByteValue.Clone(), seed => walletEncryptor.EncryptWallet(seed, confirmPasswordField.InputFieldBytes, OnNewWalletEncrypted))); }
/// <summary> /// Displays the asset transfer request details. /// </summary> /// <param name="transactionInput"> The input of the send asset transaction request. </param> protected override void InternalSetConfirmationValues(object[] transactionInput) { tradableAssetImageManager.LoadImage(tradableAssetManager.GetTradableAsset(transactionInput[1].ToString()).AssetSymbol, img => assetImage.sprite = img); amountText.text = "-" + transactionInput[2].ToString().LimitEnd(20 - transactionInput[3].ToString().Length, "...") + " <style=Symbol>" + transactionInput[3] + "</style>"; toAddress.text = transactionInput[0].ToString(); CheckIfSavedContact(toAddress.text, contactName); fromAddress.text = userWalletManager.GetWalletAddress(); CheckIfSavedContact(fromAddress.text, walletName); feeText.text = "-" + dynamicDataCache.GetData("txfee") + "<style=Symbol> ETH</style>"; }
//[ReflectionProtect] private void StartWordAnimation() { mnemonicWords = WalletUtils.GetMnemonicWords(dynamicDataCache.GetData("mnemonic")); wordFields.ForEach(f => f.AnimateColor(UIColors.White, 0.1f)); Animating = true; Random rand = new Random(); List <GameObject> randomizedWordList = new List <GameObject>(words); randomizedWordList.Sort((_, __) => rand.Next(-1, 1)); ProcessWordAnimation(randomizedWordList, 0); }
public void Construct( HopeWalletInfoManager hopeWalletInfoManager, UserWalletManager userWalletManager, WalletPasswordVerification walletPasswordVerification, LogoutHandler logoutHandler, DynamicDataCache dynamicDataCache, ButtonClickObserver buttonClickObserver) { this.walletPasswordVerification = walletPasswordVerification; this.logoutHandler = logoutHandler; this.dynamicDataCache = dynamicDataCache; this.buttonClickObserver = buttonClickObserver; walletName = hopeWalletInfoManager.GetWalletInfo(userWalletManager.GetWalletAddress()).WalletName; formTitle.text = walletName; SetMessageText(); (dynamicDataCache.GetData("pass") as ProtectedString)?.SetValue(RandomBytes.Secure.SHA3.GetBytes(16)); }
//[ReflectionProtect] public void SignTransaction <T>( Action <TransactionSignedUnityRequest> onTransactionSigned, BigInteger gasLimit, BigInteger gasPrice, BigInteger value, string addressFrom, string addressTo, string data, string path, params object[] displayInput) where T : ConfirmTransactionPopupBase <T> { var promise = (dynamicDataCache.GetData("pass") as ProtectedString)?.CreateDisposableData(); promise.OnSuccess(disposableData => { byte[] encryptedPasswordBytes = GetEncryptedPass(disposableData.ByteValue); popupManager.GetPopup <T>(true) .SetConfirmationValues(() => walletTransactionSigner.SignTransaction(addressFrom, path, encryptedPasswordBytes, onTransactionSigned), gasLimit, gasPrice, displayInput); }); }
private void CopyMnemonic() { ClipboardUtils.CopyToClipboard(dynamicDataCache.GetData("mnemonic")); }