Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: implement new CipherSeed and upgrade encryption KDF #3505

Merged

Conversation

philipr-za
Copy link
Contributor

Description

This PR adds a new CipherSeed implementation for use a seed for Key Derivation. The goal of the scheme is produce a wallet seed that is versioned, contains the birthday of the wallet, starting
entropy of the wallet to seed key generation, can be enciphered with a passphrase and has a checksum. During this process it was noted that we used a naive method to derive our database encryption key from the passphrase. This PR also updates that method to use Argon2 as a proper password hashing scheme that is not vulnerable to rainbow table brute forcing and timing attacks.

  • Update db encryption key generation to use Argon2 KDF
  • Persist the Argon2 salted hash in the DB to detect when encryption has been applied
  • Implement a CipherSeed scheme based on aezeed that can be encoded using the Mnemonic seed words
  • Integrate the new CipherSeed into the KeyManagers
  • Update Wallet backend and Clients to use the new CipherSeeds

Motivation and Context

The CipherSeed scheme has three main benefits

  • It contains the seed birthday which means we perform recoveries more efficiently and not scan the whole blockchain
  • It contains a checksum to verify the seed phrase is correct
  • It can be encrypted with a passphrase and decrypted and authenticated. We don’t current’y use a passphrase on the seeds. That will be future work.

How Has This Been Tested?

Test have been updated

This PR adds a new CipherSeed implementation for use a seed for Key Derivation. The goal of the scheme is produce a wallet seed that is versioned, contains the birthday of the wallet, starting
entropy of the wallet to seed key generation, can be enciphered with a passphrase and has a checksum. During this process it was noted that we used a naive method to derive our database encryption key from the passphrase. This PR also updates that method to use Argon2 as a proper password hashing scheme that is not vulnerable to rainbow table brute forcing and timing attacks.

- Update db encryption key generation to use Argon2 KDF
- Persist the Argon2 salted hash in the DB to detect when encryption has been applied
- Implement a CipherSeed scheme based on aezeed that can be encoded using the Mnemonic seed words
- Integrate the new CipherSeed into the KeyManagers
- Update Wallet backend and Clients to use the new CipherSeeds

The CipherSeed scheme has three main benefits
- It contains the seed birthday which means we perform recoveries more efficiently and not scan the whole blockchain
- It contains a checksum to verify the seed phrase is correct
- It can be encrypted with a passphrase and decrypted and authenticated. We don’t current’y use a passphrase on the seeds. That will be future work.
@philipr-za philipr-za force-pushed the philip-encryption-seeds branch from 76a16e6 to 7b866dd Compare October 28, 2021 07:12
SWvheerden
SWvheerden previously approved these changes Oct 29, 2021
Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

base_layer/key_manager/src/cipher_seed.rs Outdated Show resolved Hide resolved
@philipr-za
Copy link
Contributor Author

Just a note, I manually tested this by creating a wallet, transacting and recovering using seed words with the new CipherSeed implementation and all good.

@aviator-app aviator-app bot merged commit ef4f84f into tari-project:development Nov 4, 2021
stringhandler added a commit that referenced this pull request Nov 4, 2021
BREAKING CHANGES

* implement new CipherSeed and upgrade encryption KDF (#3505)

Features

* add a Rejected status to TransactionStatus ([#3512](#3512)) ([c65a01c](c65a01c))
* add caching and clippy annotations to CI ([#3518](#3518)) ([beacb9e](beacb9e))
* implement new CipherSeed and upgrade encryption KDF ([#3505](#3505)) ([ef4f84f](ef4f84f))

Bug Fixes

* edge case fix for integer pair iter ([#3508](#3508)) ([097e3e2](097e3e2))
* header sync must allow transition to archival/pruned if tip is behind ([#3520](#3520)) ([e028386](e028386))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants