From a298fca08e99b32114b4f684fb93e2bde56e6cdd Mon Sep 17 00:00:00 2001
From: Vincent Texier <vit@free.fr>
Date: Wed, 22 Jun 2022 11:05:59 +0200
Subject: [PATCH] =?UTF-8?q?Mettre=20=C3=A0=20jour=20rfc/0019=5FDuniter=5FV?=
 =?UTF-8?q?2=5Fderivation=5Fpath=5Fconvention=5Fhd=5Fwallets.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ...2_derivation_path_convention_hd_wallets.md | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/rfc/0019_Duniter_V2_derivation_path_convention_hd_wallets.md b/rfc/0019_Duniter_V2_derivation_path_convention_hd_wallets.md
index 8b13789..5161655 100644
--- a/rfc/0019_Duniter_V2_derivation_path_convention_hd_wallets.md
+++ b/rfc/0019_Duniter_V2_derivation_path_convention_hd_wallets.md
@@ -1 +1,72 @@
+# Duniter V2S conventions for Hierarchical Deterministic Wallet
 
+## Master seed generation
+
+Master seed should be generated from a [BIP-39-Mnemonic].
+
+## Key derivation
+
+Key derivation should use [Substrate-Derivation-Path] specifications.
+
+## Key derivation scheme
+
+First derivation step should be an hardened derivation and represent an `account_id`.
+
+    <mnemonic>//<account_id>
+
+`account_id` is an integer beetween `0` and `(2^24) - 1`.
+
+There are 3 types of accounts :
+
+| Account type | `account_id` value conditions |
+|-|-|
+| Member | `account_id == 0` |
+| Transparent | `account_id != 0 && account_id % 2 == 0`  |
+| Opaque | `account_id % 2 == 1` |
+
+* **Transparent:** Classic non-member wallet  (even)
+* **Opaque:** A wallet using single-use public keys for each payment received and for each payment to oneself (odd).
+
+### Opaque account derivation scheme
+
+For **self-payment**, it is first necessary to derive the so-called "internal keypair", by derivation `//1` from the opaque account keypair.
+
+    <mnemonic>//<account_id>//1
+
+Then, each single-use public key is obtained by soft derivation of the "internal public key".
+
+    <mnemonic>//<account_id>//1/i
+
+Where `i` is the payment to oneself number, beginning from 1.
+
+For **external payments**, it is first necessary to derive the so-called "external keypair", by derivation `//0` from the opaque account keypair.
+
+    <mnemonic>//<account_id>//0
+
+Then, each single-use public key is obtained by soft derivation of the "external public key".
+
+    <mnemonic>//<account_id>//0/i
+
+Where `i` is the public key derivation number, beginning from 1.
+
+[BIP-39-Mnemonic]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
+[Substrate-Derivation-Path]: https://docs.substrate.io/v3/tools/subkey/
+
+### Examples
+
+#### Example 1
+
+* **Mnemonic:** `"acquire flat utility climb filter device liberty beyond matrix satisfy metal essence"`
+* **Seed:** `0xc7de9b8c771078445f31b7e7ce0ef58b588ac37f85359527b7267ac3ad2d25f5`
+* **Address:** `5HBUc4C28AWThgPZ47TKoY9RTebMJbkfrLKWveWH6EzfAye4`
+
+* **Account ID:** `1`
+* **Type:** Opaque
+
+* **First External Public Key**
+* **Path:** `"acquire flat utility climb filter device liberty beyond matrix satisfy metal essence//1/0/1"`
+* **Address:** `5CcNUmAo5P4K9LC68fgqFKNDTcxZ7zheLeLgk4mnADXeor2K`
+
+* **Third External Public Key**
+* **Path:** `"acquire flat utility climb filter device liberty beyond matrix satisfy metal essence//1/0/3"`
+* **Address:** `5FpnSswqc97MScQ8cvEjXcT13kNBuNArJKFCxUU6SqeYoBrN`
-- 
GitLab