From 811f0e7d2d6811055f73e30085acf49bf14208e4 Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Mon, 8 Feb 2021 15:13:22 +0100 Subject: [PATCH] [DEWIF] addv4 --- ..._Duniter_Encrypted_Wallet_Import_Format.md | 60 ++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md b/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md index 7a2a396..ddef5df 100644 --- a/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md +++ b/rfc/0013_Duniter_Encrypted_Wallet_Import_Format.md @@ -75,8 +75,7 @@ Example #1: aes256 key generated from scrypt with the following parameters: -password: "user password" -salt: "user salt" +keypair seed: 0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 N : 4096 r: 16 p: 1 @@ -84,7 +83,7 @@ p: 1 ```txt 0x000000001 #v1 0x100000001 #g1-test -0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 # seed +0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 # keypair seed 0x17df9d2b059cdd2825955691e3a783e6da403148ddebb1144d1a9b9e545f2371 # public key ``` @@ -142,17 +141,16 @@ Example #2: aes256 key generated from scrypt with the following parameters: -password: "user password" -salt: "user salt" +keypair seed: 0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 N : `2^15 = 32768` r: 16 p: 1 ```txt -0x000000001 #v1 +0x000000003 #v3 0x100000001 #g1-test 0x0F # log N -0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 # seed +0xbfa3f6e322cf21d0e652f79a69df9498fdf5347665e5646d9041f756496a1143 # keypair seed 0x17df9d2b059cdd2825955691e3a783e6da403148ddebb1144d1a9b9e545f2371 # public key ``` @@ -160,4 +158,52 @@ DEWIF base 64 string (with aes key `"toto titi tata"`): `AAAAAxAAAAEPdMuBFXF4C6GZPGsJDiPBbacpVKeaLoJwkDsuqLjkwof1c760Z5iVpnZlLt5XEFlEehbdtLllVhccf9OK6Zjn8A==` +### v4 + +Version 4 stores an HD wallet according to the [BIP32-Ed25519] specifications. + +v4 data : + +| `log N` | Encrypted data | +|:-------:|:--------------:| +| 1 byte | 64 bytes | + +Encrypted data : + +| seed(32 bytes) | public key(32bytes) | +|:--------------:|:-------------------:| +| seed bytes | public key bytes | + +The public key serves as a checksum. To check that the DEWIF base64 string is not corrupted, generate a [BIP32-Ed25519] keypair with the seed and check that the obtained public key matches. + +Symmetric encryption algorithm : aes256 + +aes256 key: scrypt of user passphrase with the following parameters: + +password: passphrase +salt: sha256("dewif" ++ passphrase) +N : `2^(log N)` +r: 16 +p: 1 + +Example #3: + +keypair seed: 0xb7d3a54e1c20172cd38e0d803776a3bacf11f895ef8ef846043a0d628431c872 +N : `2^15 = 32768` +r: 16 +p: 1 + +```txt +0x000000004 #v4 +0x100000001 #g1-test +0x0F # log N +0xb7d3a54e1c20172cd38e0d803776a3bacf11f895ef8ef846043a0d628431c872 # keypair seed +0xd1fec6ddf6e887e40bd77d459131ee5a6bec1194341b9393ead606363bb7b060 # public key +``` + +DEWIF base 64 string (with aes key `"toto titi tata"`): + +`AAAABBAAAAEPcE3yXhA0T0iElXR/vDbZTRSmdec26lWu42mWKuaczzxZ22bIGVfLmlhfVW9NWmWY7m/P/j0W6Su4QZEiERe8vA==` + +[BIP32-Ed25519]: https://drive.google.com/file/d/0ByMtMw2hul0EMFJuNnZORDR2NDA/view [DUBP]: https://git.duniter.org/nodes/common/doc/blob/master/rfc/0010_Duniter_Blockchain_Protocol_V12.md -- GitLab