EOSIO RFC: 2FA on EOS blockchain

in #eos6 years ago (edited)

2FA.jpg

Requirement:

EOS blockchain users should be able to opt-in for 2FA on their accounts. As soon as the 2FA is enable on one account, all the changes on that account should go through the 2FA workflow (that includes disabling 2FA setting, changing the permissions on the account, transferring tokens from the account).

Implementation details:

  1. A new table 2faaccounts (account name, 2FA flag, encrypted email address) is needed to store the users that opt-in for 2FA
  2. Each transaction signed by the user which has opted-in for 2FA is not sent right away for processing pool but put in another transactions pool '2FA transactions pool' along with a unique encrypted 2FA code, and with an expiration time of 5 min (can be adjustable, expiration time could be stored in the table 2faaccounts), and sends an email containing the unencrypted 2FA code to the email address of the account stored in 2faaccounts table.
  3. If a transaction is received which references one of the transactions IDs stored in '2FA transactions pool' and it contains a 2FA code that is matching the decrypted 2FA code saved along with the transaction ID stored in '2FA transactions pool' then the transaction stored in '2FA transactions pool' is deleted from the pool, mark as valid and sent to the processing pool.
  4. If a transaction stored in '2FA transactions pool' expires, it is deleted from the pool, marked as not valid and sent to processing pool, where it will just be stored in the chain as an invalid 2FA transaction.

Chain user workflow

Enable 2FA:
1.1. to enable 2FA user sends an action 'enable2fa' to contract 'eosio.system' with param account name and an email string as the third param
1.2. user receives email with the 2FA code
1.3. user sends a second action 'enable2fatk' to contract 'eosio.system' with the first transaction ID, and the 2FA code received via email
1.4. if the 2FA code is correct user has opted-in for 2FA from here onwards, the initial transaction is processed and stored on the blockchain

Disable 2FA:
2.1. to disable 2FA user sends an action 'disable2fa' to contract 'eosio.system' with param account name and a value of false
2.2. user receives email with the 2FA code
2.3. user sends a second action 'disable2fatk' which contains the ID of the first transaction, and the 2FA code received via email.
2.4. if the 2FA code is correct user has opted out of 2FA from here onwards, the initial transaction is processed and is stored on the blockchain

Tranfer tokens:
3.1. user sends an action 'transfer' to contract 'eosio.token'
3.2. user receives an email with 2FA code
3.3. user sends a second action 'transfer2fatk' with the 2FA code received via email
3.4. if the 2FA code is correct the initial transfer is processed and stored on the blockchain

Wallet user workflow

Transfer tokens:
1.1. user authenticates using the wallet
1.2. user sends some money to another account
1.3. user is announced by the wallet presentation view that he has to check his email for the 2FA code
1.4. user enters the 2FA code into the wallet and confirms the transfer transaction
1.5. transfer transaction is done

Enable 2FA:
1.1. user authenticates using the wallet
1.2. user enables 2FA using the wallet presentation view
1.3. wallet presentation view is asking for user email address to use in 2FA process
1.4. user confirms his email address and sends the transaction using the wallet
1.5. user is announced by the wallet presentation view he has to check his email for the 2FA code
1.6. user enters the 2FA code into the wallet and confirms the 'enable 2FA transaction'
1.7. user has now 2FA enabled

Disable 2FA:
1.1. user authenticates using the wallet
1.2. user disables 2FA using the wallet presentation view
1.3. user is announced by the wallet presentation view he has to check his email for the 2FA code
1.4. user enters the 2FA code into the wallet and confirms the 'disable 2FA transaction'
1.5. user has now 2FA disabled

The 2FA can be achieved in similar manner via TOTP (google authenticator), along side with email approach. Ideally both should be available for the user to chose from, and both should be implemented so the decentralized degree of the chain is not altered/lost.

Please let us know your thoughts and comments. If this would be implemented we believe benefits are clear.
@worbli @telos @wax @enumivo @evolutionos @eosio

Thank you,
eosromania22

Sort:  

How is it different from multisig, which is currently possible if I remember correctly?

For this to work you'll have trust a third party (other than blockchain) to cross sign your transactions if you provide correct 2FA code.
Or you can set up your account with two keys weighted in a sum of 1, and then sign each transaction/transfer from two different wallets each holding one of the keys. This can work too yes. Instead of 2FA user will manage two wallets.
However both approaches are presenting different pros and cons compared with 2FA intrinsic to the chain, which is perceived as been the most user friendly.

Thank you for all who provided feedback.
The problem with the presented approach is this: when second action is sent with the 2FA code, there's a high chance the BP that will process it to not be the BP that processed the first action, the same BP that generated the 2FA code, and sent it via email to the user; because of that the BP that processes the second action can not decrypt the 2FA code stored by the first BP (unless it is the same BP). For this to be solved the second BP has to encrypt the stored 2FA code as well, first BP decrypt it and now the second BP can decrypt it using its key (employ the asymmetric key encryption flow).

Other resources:
https://www.thinkmind.org/download.php?articleid=iciw_2017_4_10_20037
https://bitcointalk.org/index.php?topic=603531.0

Congratulations @unus! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 100 upvotes. Your next target is to reach 200 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @unus! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Are you a DrugWars early adopter? Benvenuto in famiglia!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!