How to use the bitsharesjs.Aes.fromSeed function in bitsharesjs

To help you get started, we’ve selected a few bitsharesjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitshares / bitshares-ui / app / stores / WalletDb.js View on Github external
return new Promise(resolve => {
            let wallet = this.state.wallet;
            let {success} = this.validatePassword(old_password);
            if (!success) throw new Error("wrong password");

            let old_password_aes = Aes.fromSeed(old_password);
            let new_password_aes = Aes.fromSeed(new_password);

            if (!wallet.encryption_key)
                // This change pre-dates the live chain..
                throw new Error(
                    "This wallet does not support the change password feature."
                );
            let encryption_plainbuffer = old_password_aes.decryptHexToBuffer(
                wallet.encryption_key
            );
            wallet.encryption_key = new_password_aes.encryptToHex(
                encryption_plainbuffer
            );

            let new_password_private = PrivateKey.fromSeed(new_password);
            wallet.password_pubkey = new_password_private
github bitshares / bitshares-ui / app / stores / WalletDb.js View on Github external
return new Promise(resolve => {
            let wallet = this.state.wallet;
            let {success} = this.validatePassword(old_password);
            if (!success) throw new Error("wrong password");

            let old_password_aes = Aes.fromSeed(old_password);
            let new_password_aes = Aes.fromSeed(new_password);

            if (!wallet.encryption_key)
                // This change pre-dates the live chain..
                throw new Error(
                    "This wallet does not support the change password feature."
                );
            let encryption_plainbuffer = old_password_aes.decryptHexToBuffer(
                wallet.encryption_key
            );
            wallet.encryption_key = new_password_aes.encryptToHex(
                encryption_plainbuffer
            );

            let new_password_private = PrivateKey.fromSeed(new_password);
            wallet.password_pubkey = new_password_private
                .toPublicKey()
github bitshares / bitshares-ui / app / stores / WalletDb.js View on Github external
if (typeof brainkey_plaintext !== "string")
                        throw new Error("Brainkey must be a string");

                    if (brainkey_plaintext.trim() === "")
                        throw new Error("Brainkey can not be an empty string");

                    if (brainkey_plaintext.length < 50)
                        throw new Error(
                            "Brainkey must be at least 50 characters long"
                        );

                    // The user just provided the Brainkey so this avoids
                    // bugging them to back it up again.
                    brainkey_backup_date = new Date();
                }
                let password_aes = Aes.fromSeed(password_plaintext);

                let encryption_buffer = key.get_random_key().toBuffer();
                // encryption_key is the global encryption key (does not change even if the passsword changes)
                let encryption_key = password_aes.encryptToHex(
                    encryption_buffer
                );
                // If unlocking, local_aes_private will become the global aes_private object
                let local_aes_private = Aes.fromSeed(encryption_buffer);

                if (!brainkey_plaintext)
                    brainkey_plaintext = key.suggest_brain_key(dictionary.en);
                else
                    brainkey_plaintext = key.normalize_brainKey(
                        brainkey_plaintext
                    );
                let brainkey_private = this.getBrainKeyPrivate(
github GamechainSystem / GameChainBase / GameChainBlockWallet / app / components / wallet / ImportKey.js View on Github external
onQrcodePasswordEnter(e) {
        e.preventDefault();
        let pwd = this.refs.qrcode_pwd_input.value;
        let pwd_aes = Aes.fromSeed(pwd);
        let wif = pwd_aes.decryptHexToText(this.props.qrcode);
        //let w2 = pwd_aes.decryptHex(this.props.qrcode);
        //console.log("dec qr:", this.props.qrcode, wif, w2);
        if (wif == null || wif.length != 51) {
            this.setState({qrcode_password_error: this.formatMessage("wallet_passwordErrMsg")});
        } else {
            this.setState({wif: wif, encrypt_wif: false, qrcode_password_error: null});
            ScanActions.reset();
        }
    }
github bitshares / bitshares-ui / app / stores / WalletDb.js View on Github external
return {success: !!_passwordKey, cloudMode: true};
        } else {
            let wallet = this.state.wallet;
            try {
                let password_private = PrivateKey.fromSeed(password);
                let password_pubkey = password_private
                    .toPublicKey()
                    .toPublicKeyString();
                if (wallet.password_pubkey !== password_pubkey) return false;
                if (unlock) {
                    let password_aes = Aes.fromSeed(password);
                    let encryption_plainbuffer = password_aes.decryptHexToBuffer(
                        wallet.encryption_key
                    );
                    aes_private = Aes.fromSeed(encryption_plainbuffer);
                }
                return {success: true, cloudMode: false};
            } catch (e) {
                console.error(e);
                return {success: false, cloudMode: false};
            }
        }
    }
github bitshares / bitshares-ui / app / stores / WalletDb.js View on Github external
});
                    return {success: true, cloudMode: false};
                }
            }

            return {success: !!_passwordKey, cloudMode: true};
        } else {
            let wallet = this.state.wallet;
            try {
                let password_private = PrivateKey.fromSeed(password);
                let password_pubkey = password_private
                    .toPublicKey()
                    .toPublicKeyString();
                if (wallet.password_pubkey !== password_pubkey) return false;
                if (unlock) {
                    let password_aes = Aes.fromSeed(password);
                    let encryption_plainbuffer = password_aes.decryptHexToBuffer(
                        wallet.encryption_key
                    );
                    aes_private = Aes.fromSeed(encryption_plainbuffer);
                }
                return {success: true, cloudMode: false};
            } catch (e) {
                console.error(e);
                return {success: false, cloudMode: false};
            }
        }
    }
github bitshares / bitshares-ui / app / components / Wallet / ImportKeys.jsx View on Github external
_decryptPrivateKeys(password) {
        let password_aes = Aes.fromSeed(password);
        let format_error1_once = true;
        for (let account of this.state.account_keys) {
            if (!account.encrypted_private_keys) {
                let error = `Account ${
                    account.account_name
                } missing encrypted_private_keys`;
                console.error(error);
                if (format_error1_once) {
                    Notification.error({
                        message: error
                    });
                    format_error1_once = false;
                }
                continue;
            }
            let account_name = account.account_name.trim();
github bitshares / bitshares-ui / app / components / Modal / QrcodeModal.jsx View on Github external
onPasswordEnter(e) {
        e.preventDefault();
        let pwd = this.refs.password_input.value;
        let key = this.props.keyValue;
        if (pwd != null && pwd != "") {
            if (key !== undefined && key != null && key != "") {
                let pwd_aes = Aes.fromSeed(pwd);
                let qrkey = pwd_aes.encryptToHex(key);
                this.setState({isShowQrcode: true, keyString: qrkey});
            }
        } else {
            //notify.error("You'd better enter a password to encrypt the qr code");
            this.setState({isShowQrcode: true, keyString: key});
        }
    }