Skip to content

Commit 3f6f1f8

Browse files
authored
Merge pull request bitcoin#604 from commerceblock/master
Adding payment_base to the derivation path as an extra step of security
2 parents 0402dd2 + b63ed0e commit 3f6f1f8

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

bip-0175.mediawiki

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Hardened derivation is used at this level.
7474

7575
===Payment address generation===
7676

77-
For a given contract documents denoted by c<sub>1</sub> ,...,c<sub>n</sub>, payment base extended public key denoted by <code>payment_base</code>, and cryptographic hash function denoted by <code>h</code>.
77+
For a given contract documents denoted by c<sub>1</sub>,...,c<sub>n</sub>, payment base extended public key denoted by <code>payment_base</code>, and cryptographic hash function denoted by <code>h</code>.
7878

7979
1. Compute cryptographic hashes for all contract documents, by applying the hash function.
8080

@@ -84,9 +84,9 @@ For a given contract documents denoted by c<sub>1</sub> ,...,c<sub>n</sub>, paym
8484

8585
hash_1,...,hash_n
8686
87-
3. Concatenate the sorted hashes and apply the hash function.
87+
3. Prepend payment_base and concatenate the sorted hashes and apply the hash function.
8888

89-
h(hash_1+...+hash_n)
89+
h(payment_base+hash_1+...+hash_n)
9090
9191
4. Compute a partial BIP32 derivation path from the combined hash as defined in Hash to Partial Derivation Path Mapping procedure below.
9292

@@ -171,28 +171,28 @@ document 2:
171171
172172
3. Concatenate hashes and apply the hash function.
173173

174-
concatenated hash:
175-
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7aefcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9
174+
concatenated hash: payment_base
175+
xpub6B3JSEWjqm5GgfzcjPwBixxLPzi15pFM3jq4E4yCzXXUFS5MFdXiSdw7b5dbdPGHuc7c1V4zXbbFRtc9G1njMUt9ZvMdGVGYQSQsurD6HAW2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7aefcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9
176176
combined hash:
177-
ec321de56af3b66fb49e89cfe346562388af387db689165d6f662a3950286a57
177+
310057788c6073640dc222466d003411cd5c1cc0bf2803fc6ebbfae03ceb4451
178178
179179
4. Compute the partial BIP32 derivation path of the combined hash.
180180

181-
60466/7653/27379/46703/46238/35279/58182/22051/34991/14461/46729/5725/28518/10809/20520/27223
181+
12544/22392/35936/29540/3522/8774/27904/13329/52572/7360/48936/1020/28347/64224/15595/17489
182182
183183
5. Prepend <code>payment_base</code> to <code>contract_hash</code> derivation path.
184184

185-
contract_base_pub/60466/7653/27379/46703/46238/35279/58182/22051/34991/14461/46729/5725/28518/10809/20520/27223
185+
contract_base_pub/12544/22392/35936/29540/3522/8774/27904/13329/52572/7360/48936/1020/28347/64224/15595/17489
186186
or
187-
m/175'/0'/60466/7653/27379/46703/46238/35279/58182/22051/34991/14461/46729/5725/28518/10809/20520/27223
187+
m/175'/0'/12544/22392/35936/29540/3522/8774/27904/13329/52572/7360/48936/1020/28347/64224/15595/17489
188188
189189
6. Compute public extended key.
190190

191-
xpub6hML7vSU2Hwww9ctwrwt4ijnhJr4n6XaMRox1nnF3PvZKuF1SZoTymnKQHrF9fp2nWJSqv5ZjJSxJJQ8A3PKcBUWhGvTFmuRKpycSCr5coz
191+
xpub6hefaATTG5LbcwyPDvmNfnkyzefoM2TJDoo5astH7Gvs1g8vZURviBWvAvBnWc2CNb8ybJ6mDpnQYVsvNSZ3oUmbssX3rUVG97TFYa6AXVk
192192
193193
7. Compute address of the public extended key (P2PKH).
194194

195-
1HYjhPTtMmpBJBd5tVepZDAVdvPA7o8KHJ
195+
1C7f322izqMqLzZzfzkPAjxBzprxDi47Yf
196196
197197

198198
====Verification example (negative test)====
@@ -207,29 +207,33 @@ document 1:
207207

208208
baa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096
209209
210-
2. Apply the hash function a second time (list of one item).
210+
2. Prepend payment_base
211+
212+
xpub6B3JSEWjqm5GgfzcjPwBixxLPzi15pFM3jq4E4yCzXXUFS5MFdXiSdw7b5dbdPGHuc7c1V4zXbbFRtc9G1njMUt9ZvMdGVGYQSQsurD6HAWbaa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096
213+
214+
2. Apply hash function
211215

212216
3a08605829413ce0bf551b08d21e4a28dbda6e407f90eff1c448e839050c73a1
213217
214218
3. Compute the partial derivation path.
215219

216-
14856/24664/10561/15584/48981/6920/53790/18984/56282/28224/32656/61425/50248/59449/1292/29601
220+
5338/54412/19213/962/30664/62597/11873/59874/56779/24089/54550/19585/28087/36422/18666/17562
217221
218222
4. Prepend contract_base<sub>pub</sub> to contract_hash derivation path.
219223

220-
contract_base_pub/14856/24664/10561/15584/48981/6920/53790/18984/56282/28224/32656/61425/50248/59449/1292/29601
224+
contract_base_pub/5338/54412/19213/962/30664/62597/11873/59874/56779/24089/54550/19585/28087/36422/18666/17562
221225
or
222-
m/175'/0'/14856/24664/10561/15584/48981/6920/53790/18984/56282/28224/32656/61425/50248/59449/1292/29601
226+
m/175'/0'/5338/54412/19213/962/30664/62597/11873/59874/56779/24089/54550/19585/28087/36422/18666/17562
223227
224228
5. Compute public extended key.
225229

226-
xpub6gujKWRhegHXKZBkrprW55oSL6UxYhStxF5FtoUNa4KShLxLPDLQTS39XAwRhdCSvuAv2wogwukmfk3fS7CM6pT6QWwJHiCTw7RkwXMgThy
230+
xpub6h9k2KqsMpwghxt7naj1puhGV1ZDC88sxvpYN1HibCf8yQZdPsuhYmmvdK32Kf2Lb3rS1sV8UcZ1f84DJEiXuVfLCAj4bC85aEUCxh38m8i
227231
228232
7. Compute address of the public extended key (P2PKH).
229233

230-
162KDdRXa3KPgYkH3d1DDKfddacH1gn1n8
234+
1QGe5LaDMAmHeibJbZBmZqhQDZSp7QCqSs
231235
232-
8. As expected the address doesn't match the Bitcoin address from the last example <code>1LeYXs63uVSDu2XSb82xdEc7RumohCpB7Q</code>.
236+
8. As expected the address doesn't match the Bitcoin address from the last example <code>1C7f322izqMqLzZzfzkPAjxBzprxDi47Yf</code>.
233237

234238
Verification operation will succeed only if we use identical documents to ones that have been used in the contract address generation.
235239

0 commit comments

Comments
 (0)