Difference between revisions of "Wallet Encryption"

From DeFiChain-Wiki
(Created page with "Disclaimer: The following might contain wrong or incomplete information. Unfortunately the following will only describe and explain a certain scenario and prevention but canno...")
 
(Complete rework)
Line 1: Line 1:
 +
THIS PAGE IS UNDER CONSTRUCTION CURRENTLY!
 +
 +
 
Disclaimer: The following might contain wrong or incomplete information. Unfortunately the following will only describe and explain a certain scenario and prevention but cannot provide a solution for common problems that have been reported.
 
Disclaimer: The following might contain wrong or incomplete information. Unfortunately the following will only describe and explain a certain scenario and prevention but cannot provide a solution for common problems that have been reported.
==Problem description==
 
While creating a wallet in the DefiChain app, you normally create a mnemonic phrase, consisting of 24 words. You are well advised to keep the phrase at a safe place. The wallet creates a seed and private and public keys from the phrase, as well as addresses to receive DFI (this is technically very simplified here). Usually, it seems to be the expectation of users that in case of a failure (wallet deleted, corrupted, …) it is enough to use the phrase while creating a fresh wallet and all keys and addresses are restored since they are determined from the phrase. And usually this works fine.[[File:Seed_encryption.jpg|250px|thumb|Seed before & after encryption]]The DeFiChain Wiki contains an article about [https://github.com/DeFiCh/app/wiki/Wallet-Encryption Wallet encryption] using the console of the app. The article contains a notice that using the encryption function will change the seed. In consequence the phrase created at the beginning is useless since it can only re-create the status '''before''' the encryption was turned on. This seems to be an explanation for the reported issue that after restoring the wallet with the mnemonic phrase users are missing the addresses, which are created after the encryption of the Wallet. When checking with ''getaddressinfo <address>'' it shows ''ismine:false''. Fair enough since this address was not created by the seed derived from the phrase but from the seed created during encryption.
 
==Prevention==
 
The only way to prevent this problem is to backup the actual ''wallet.dat'' file after the encryption. You can backup the wallet.dat file on the Wallet-App (since version 2.1.16) if you click on '''Wallet''' on the taskbar.[[File:Backup_Wallet.png|250px|thumb|Backup wallet in app]]If you want to save the wallet.dat manually, it is located at:
 
  
Linux: ~/.defi/wallets
+
== Why encryption matters ==
 +
The DeFiChain App stores relevant data of your wallet in a file called "wallet.dat", which is located at:
 +
 
 +
* Linux: ~/.defi/wallets
 +
* Mac: ~/Library/Application Support/DeFi/wallets
 +
* Windows: <root>\Users\<username>\AppData\Roaming\DeFi Blockchain\wallets
 +
 
 +
This file works in many aspects jsut as in Bitcoin core since DeFiChain is a fork of Bitcoin. The wallet.dat stores your seed and private keys, as well as all public keys and addresses. All keys and addresses are determined from the seed using cryptographic methods (so called hierarchical deterministuc wallet, short HD wallet according to BIP ). If the wallet.dat file is unecrypted (this has been the standard up to version 2.3.0 of the app), all data stored in the file was openly available to everbody who was getting access to that file. So in case the file got in the wrong hands, all funds can be moved to another address and therefore be stolen.
 +
 
 +
So users should be advised to encrypt their wallet and since version 2.3.0 the app is actively encouraging that.
 +
 
 +
After encryption of wallet.dat all data in the file is encrypted and can only be used in the app after unlocking the wallet.dat by entering the password. Before 2.3.0 initial encryption of the wallet.dat and temporary decryption by entering the password could be done in the command line only. Version 2.3.0 added GUI support for this.
 +
==Encryption in the DeFiChain App==
  
• Mac: ~/Library/Application Support/DeFi/wallets
+
==== App Version up to 2.1.17 ====
 +
In app versions <u>before</u> 2.3.0 (i.e. up to 2.1.17) the creation of a new wallet started with the creation a mnemonic phrase, consisting of 24 words. This is what most users refer to as their "seed". Technically the app derived a seed from that phrase and private/public keys and addresses from the seed. The general expectation of users is that having the phrase would be enough to recover the wallet (after computer crash, reinstallation, ...) including all keys and addresses. The DeFiChain GitHub Wiki contains an article about [https://github.com/DeFiCh/app/wiki/Wallet-Encryption Wallet encryption] using the command line of the app. The article contains a notice that using the encryption function will change the seed. In consequence the phrase created at the beginning is useless since it can only re-create the status '''before''' the encryption was turned on. This seems to be an explanation for the reported issue that after restoring the wallet with the mnemonic phrase users are missing the addresses, which are created after the encryption of the Wallet. When checking with ''getaddressinfo <address>'' it shows ''ismine:false''. Fair enough since this address was not created by the seed derived from the phrase but from the seed created during encryption. [[File:Backup_Wallet.png|250px|thumb|Backup wallet in app]]
 +
Even after encryption is enabled, the app keeps the keys and addresses derived from the original seed in the wallet. So access to the funds is still possible. However, the old addresses have been marked with a warning that they a not saved by the seed (the new seed after encryption).
  
• Windows: <root>\Users\<username>\AppData\Roaming\DeFi Blockchain\wallets
+
How to backup with enabled encryption: Keep the mnemonic phrase and a copy of wallet.dat or a backup made with the backup function of the app. The backup function in 2.1.16 and 2.1.17 creates a backup in .dat format which is useful to restore also in newer version. Former versions created unecrypted backup in .txt files that are deemed to be not secure and are not feasible for restoring a wallet in new versions.
  
Since version 2.1.16 the DeFiChain app has the possibility to create backups of the ''wallet.dat'' from the GUI. In former version the app created an unecrypted .txt file as backup.
+
In short: for encrypted wallets the mnemonic phrase is usually not enough to recover a wallet from scratch. The phrase can be used to restore the keys and addresses before encryption was turned on. Keep the phrase and a backup of wallet.dat at a safe place.
  
Unfortunately there is no solution to recover addresses from an encrypted ''wallet.dat'' without the actual file (backup). This was also probably never intended in Bitcoin Core.
+
==== App version 2.3.0 ====
 +
[[File:Seed_encryption.jpg|250px|thumb|Seed before & after encryption]]
 +
==Summary==

Revision as of 12:03, 5 March 2021

THIS PAGE IS UNDER CONSTRUCTION CURRENTLY!


Disclaimer: The following might contain wrong or incomplete information. Unfortunately the following will only describe and explain a certain scenario and prevention but cannot provide a solution for common problems that have been reported.

Why encryption matters

The DeFiChain App stores relevant data of your wallet in a file called "wallet.dat", which is located at:

  • Linux: ~/.defi/wallets
  • Mac: ~/Library/Application Support/DeFi/wallets
  • Windows: <root>\Users\<username>\AppData\Roaming\DeFi Blockchain\wallets

This file works in many aspects jsut as in Bitcoin core since DeFiChain is a fork of Bitcoin. The wallet.dat stores your seed and private keys, as well as all public keys and addresses. All keys and addresses are determined from the seed using cryptographic methods (so called hierarchical deterministuc wallet, short HD wallet according to BIP ). If the wallet.dat file is unecrypted (this has been the standard up to version 2.3.0 of the app), all data stored in the file was openly available to everbody who was getting access to that file. So in case the file got in the wrong hands, all funds can be moved to another address and therefore be stolen.

So users should be advised to encrypt their wallet and since version 2.3.0 the app is actively encouraging that.

After encryption of wallet.dat all data in the file is encrypted and can only be used in the app after unlocking the wallet.dat by entering the password. Before 2.3.0 initial encryption of the wallet.dat and temporary decryption by entering the password could be done in the command line only. Version 2.3.0 added GUI support for this.

Encryption in the DeFiChain App

App Version up to 2.1.17

In app versions before 2.3.0 (i.e. up to 2.1.17) the creation of a new wallet started with the creation a mnemonic phrase, consisting of 24 words. This is what most users refer to as their "seed". Technically the app derived a seed from that phrase and private/public keys and addresses from the seed. The general expectation of users is that having the phrase would be enough to recover the wallet (after computer crash, reinstallation, ...) including all keys and addresses. The DeFiChain GitHub Wiki contains an article about Wallet encryption using the command line of the app. The article contains a notice that using the encryption function will change the seed. In consequence the phrase created at the beginning is useless since it can only re-create the status before the encryption was turned on. This seems to be an explanation for the reported issue that after restoring the wallet with the mnemonic phrase users are missing the addresses, which are created after the encryption of the Wallet. When checking with getaddressinfo <address> it shows ismine:false. Fair enough since this address was not created by the seed derived from the phrase but from the seed created during encryption.

Backup wallet in app

Even after encryption is enabled, the app keeps the keys and addresses derived from the original seed in the wallet. So access to the funds is still possible. However, the old addresses have been marked with a warning that they a not saved by the seed (the new seed after encryption).

How to backup with enabled encryption: Keep the mnemonic phrase and a copy of wallet.dat or a backup made with the backup function of the app. The backup function in 2.1.16 and 2.1.17 creates a backup in .dat format which is useful to restore also in newer version. Former versions created unecrypted backup in .txt files that are deemed to be not secure and are not feasible for restoring a wallet in new versions.

In short: for encrypted wallets the mnemonic phrase is usually not enough to recover a wallet from scratch. The phrase can be used to restore the keys and addresses before encryption was turned on. Keep the phrase and a backup of wallet.dat at a safe place.

App version 2.3.0

Seed before & after encryption

Summary