コード例 #1
0
    /// <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;
    }
コード例 #2
0
    //[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);
    }
コード例 #3
0
    /// <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();
    }
コード例 #4
0
    /// <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);
    }
コード例 #5
0
    /// <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);
        }
    }
コード例 #6
0
    /// <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();
    }
コード例 #7
0
    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()));
    }
コード例 #8
0
        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)));
        }
コード例 #9
0
    /// <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>";
    }
コード例 #10
0
    //[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);
    }
コード例 #11
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));
    }
コード例 #12
0
ファイル: HopeWallet.cs プロジェクト: HopeWallet/Hope-Desktop
    //[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);
        });
    }
コード例 #13
0
 private void CopyMnemonic()
 {
     ClipboardUtils.CopyToClipboard(dynamicDataCache.GetData("mnemonic"));
 }