An English version is available below
Introduction
J’ai consacré beaucoup de temps ces dernières années à étudier le fonctionnement des autres crypto et à discuter avec des ingénieurs d’autres crypto, et cela m’a fait prendre conscience, entre autres choses, que nos pratiques actuelles de génération des trousseaux de clés sont dangereuses !
Vu la naissance d’une nouvelle génération de clients conséquente à l’arrivée de GVA (Tikka, Gecko, cesiumV2). C’est le meilleur moment pour repartir sur de bonnes bases en matière de génération de trousseau.
Les clients pourront évidemment proposer une authentification en mode «legacy» pour accéder aux portefeuilles existants, mais ce mode legacy ne doit pas être proposé par défaut et l’interface doit clairement indiquer à l’utilisateur que ce mode d’authentification est obsolète et ne doit être utilisé que pour accéder à un portefeuille créer de cette ancienne manière.
Comment générer le trousseau de clés ?
Une phrase de sécurité doit être générée aléatoirement, phrase de sécurité qui ne sera nécessaire à l’utilisateur que lorsqu’il changera d’appareil.
La seed doit être dérivée de cette phrase de sécurité via un protocole commun pour l’interopérabilité.
Je propose le protocole suivant :
Puis le trousseau de clés doit être stocké de manière chiffrée, avec une clé de chiffrement dérivée via scrypt, sinon il est trop facile de brute forcer le chiffrement, il y a d’autres subtilités importantes à respecter pour chiffrer correctement un trousseau, c’est pourquoi je vous recommande d’utiliser le format DEWIF :
https://git.duniter.org/documents/rfcs/blob/dewif/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md
Implémentation de référence
J’ai réalisé une implémentation de référence en Rust (intégrée dans dup-crypto) :
Un exemple d’utilisation dans la doc : dup_crypto::mnemonic::mnemonic_to_seed - Rust
Bibliothèques pour vous aider
Il existe des bibliothèques de génération de mnemonic dans quasiment tous les langages :
Python : GitHub - trezor/python-mnemonic: 🐍 Mnemonic code for generating deterministic keys, BIP39
Dart: GitHub - yshrsmz/bip39-dart: BIP39 mnemonic code implementation in Dart lang
Javascript : GitHub - bitcoinjs/bip39: JavaScript implementation of Bitcoin BIP39: Mnemonic code for generating deterministic keys
Introduction
I have spent a lot of time in the last few years studying the workings of other crypto’s and talking with engineers from other crypto’s, and this has made me realize’ among other things, that our current keychain generation practices are dangerous!
Given the birth of a new generation of customers resulting from the arrival of GVA (Tikka, Gecko, cesiumV2). This is the best time to get back on a good footing when it comes to keychain generation.
Customers will obviously be able to offer authentication in “legacy” mode to access existing portfolios, but this legacy mode should not be offered by default and the interface should clearly indicate to the user that this authentication mode is obsolete and should only be used to access a portfolio created in this old way.
How to generate the keypair?
A random passphrase must be generated which will only be necessary for the user when changing devices.
The seed must be derived from this mnemonic via a common protocol for interoperability.
I propose the following protocol:
Then the keypair must be stored encrypted, with an encryption key that must also be obtained via scrypt, otherwise it is too easy to brute force the encryption, there are other important subtleties to respect to correctly encrypt a keychain, that’s why I recommend to use the DEWIF format :
https://git.duniter.org/documents/rfcs/blob/dewif/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md
Reference implementation
I realized a reference implementation in Rust (integrated in dup-crypto) :
An example of usage in the doc: dup_crypto::mnemonic::mnemonic_to_seed - Rust
Libraries to help you
There are mnemonic generation libraries in almost all languages:
Python : GitHub - trezor/python-mnemonic: 🐍 Mnemonic code for generating deterministic keys, BIP39
Dart: GitHub - yshrsmz/bip39-dart: BIP39 mnemonic code implementation in Dart lang
Javascript : GitHub - bitcoinjs/bip39: JavaScript implementation of Bitcoin BIP39: Mnemonic code for generating deterministic keys