Skip to content

Commit 9f58824

Browse files
authored
Merge pull request bitcoin#1674 from bitcoin/revert-1600-master
Revert "BIP85: Clarify spec, correct test vectors, add Portuguese language code, add dice application"
2 parents 758dfc9 + 3f4a0a1 commit 9f58824

File tree

2 files changed

+15
-87
lines changed

2 files changed

+15
-87
lines changed

README.mediawiki

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ Those proposing changes should consider that ultimately consent may rest with th
452452
| [[bip-0085.mediawiki|85]]
453453
| Applications
454454
| Deterministic Entropy From BIP32 Keychains
455-
| Ethan Kosakovsky, Aneesh Karve
455+
| Ethan Kosakovsky
456456
| Informational
457457
| Draft
458458
|- style="background-color: #cfffcf"

bip-0085.mediawiki

+14-86
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Layer: Applications
44
Title: Deterministic Entropy From BIP32 Keychains
55
Author: Ethan Kosakovsky <[email protected]>
6-
Aneesh Karve <[email protected]>
76
Comments-Summary: No comments yet.
87
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0085
98
Status: Draft
@@ -15,10 +14,10 @@
1514

1615
==Abstract==
1716

18-
''One Seed to rule them all,''<br>
19-
''One Key to find them,''<br>
20-
''One Path to bring them all,''<br>
21-
''And in cryptography bind them.''
17+
''"One Seed to rule them all,''
18+
''One Key to find them,''
19+
''One Path to bring them all,''
20+
''And in cryptography bind them."''
2221

2322
It is not possible to maintain one single (mnemonic) seed backup for all keychains used across various wallets because there are a variety of incompatible standards. Sharing of seeds across multiple wallets is not desirable for security reasons. Physical storage of multiple seeds is difficult depending on the security and redundancy required.
2423

@@ -34,9 +33,6 @@ The terminology related to keychains used in the wild varies widely, for example
3433
# '''BIP39 mnemonic''' is the mnemonic phrase that is calculated from the entropy used before hashing of the mnemonic in BIP39.
3534
# '''BIP39 seed''' is the result of hashing the BIP39 mnemonic seed.
3635
37-
When in doubt, assume '''big endian''' byte serialization, such that the leftmost
38-
byte is the most significant.
39-
4036
==Motivation==
4137

4238
Most wallets implement BIP32 which defines how a BIP32 root key can be used to derive keychains. As a consequence, a backup of just the BIP32 root key is sufficient to include all keys derived from it. BIP32 does not have a human friendly serialization of the BIP32 root key (or BIP32 extended keys in general) which makes paper backups or manually restoring the key more error-prone. BIP39 was designed to solve this problem but rather than serialize the BIP32 root key, it takes some entropy, encoded to a "seed mnemonic", which is then hashed to derive the BIP39 seed which can be turned into the BIP32 root key. Saving the BIP39 mnemonic is enough to reconstruct the entire BIP32 keychain, but a BIP32 root key cannot be reversed back to the BIP39 mnemonic.
@@ -55,9 +51,6 @@ For each application that requires its own wallet, a unique private key is deriv
5551

5652
The HMAC-SHA512 function is specified in [http://tools.ietf.org/html/rfc4231 RFC 4231].
5753

58-
Application codes may be arbitrary but should be semantic, such as a BIP number,
59-
ASCII character code sequence, or similar.
60-
6154
===Test vectors===
6255

6356
====Test case 1====
@@ -85,7 +78,7 @@ BIP85-DRNG-SHAKE256 is a deterministic random number generator for cryptographic
8578
RSA key generation is an example of a function that requires orders of magnitude more than 64 bytes of random input. Further, it is not possible to precalculate the amount of random input required until the function has completed.
8679

8780
drng_reader = BIP85DRNG.new(bip85_entropy)
88-
rsa_key = RSA.generate_key(4096, drng_reader.read)
81+
rsa_key = RSA.generate_key(4096, drng_reader.read())
8982
9083
===Test Vectors===
9184
INPUT:
@@ -100,15 +93,14 @@ OUTPUT
10093
10194
==Reference Implementation==
10295

103-
* 2.0 Python library implementation: [https://github.com/akarve/bipsea]
104-
* 1.0 Python library implementation: [https://github.com/ethankosakovsky/bip85]
105-
* 1.0 JavaScript library implementation: [https://github.com/hoganri/bip85-js]
96+
* Python library implementation: [https://github.com/ethankosakovsky/bip85]
97+
* JavaScript library implementation: [https://github.com/hoganri/bip85-js]
10698
10799
==Applications==
108100

109101
The Application number defines how entropy will be used post processing. Some basic examples follow:
110102

111-
Derivation path uses the format <code>m/83696968'/{app}'/{index}'</code> where ''{app}'' is the '''path''' for the application, and ''{index}'' is the index.
103+
Derivation path uses the format <code>m/83696968'/{app_no}'/{index}'</code> where ''{app_no}'' is the path for the application, and ''{index}'' is the index.
112104

113105
===BIP39===
114106
Application number: 39'
@@ -151,10 +143,6 @@ Language Table
151143
|-
152144
| Czech
153145
| 8'
154-
|-
155-
| Portuguese
156-
| 9'
157-
|-
158146
|}
159147

160148
Words Table
@@ -219,12 +207,7 @@ OUTPUT:
219207
===HD-Seed WIF===
220208
Application number: 2'
221209

222-
Uses the most significant 32 bytes<ref name="curve-order">
223-
There is a very small chance that you'll make an invalid
224-
key that is zero or bigger than the order of the curve. If this occurs, software
225-
should hard fail (forcing users to iterate to the next index).</ref>
226-
of entropy as the secret exponent to derive a private key and encode as a compressed
227-
WIF which will be used as the hdseed for Bitcoin Core wallets.
210+
Uses 256 bits[1] of entropy as the secret exponent to derive a private key and encode as a compressed WIF which will be used as the hdseed for Bitcoin Core wallets.
228211

229212
Path format is <code>m/83696968'/2'/{index}'</code>
230213

@@ -239,26 +222,17 @@ OUTPUT
239222
===XPRV===
240223
Application number: 32'
241224

242-
Consistent with BIP32, use the first (leftmost) 32 bytes of the derived entropy as the
243-
private key<ref name="curve-order" />. Prepend an empty byte (<code>0x00</code>)
244-
per BIP32 on master key serialization. Use the last (rightmost) 32 bytes as the chain code.
245-
246-
Child number, depth, and parent fingerprint are forced to zero, as with any root
247-
private key.
248-
225+
Taking 64 bytes of the HMAC digest, the first 32 bytes are the chain code, and second 32 bytes[1] are the private key for BIP32 XPRV value. Child number, depth, and parent fingerprint are forced to zero.
249226

250227
Path format is <code>m/83696968'/32'/{index}'</code>
251228

252-
253-
Applications may support Testnet by emitting TPRV keys if and only if the input root key is a Testnet key.
254-
255229
INPUT:
256230
* MASTER BIP32 ROOT KEY: xprv9s21ZrQH143K2LBWUUQRFXhucrQqBpKdRRxNVq2zBqsx8HVqFk2uYo8kmbaLLHRdqtQpUm98uKfu3vca1LqdGhUtyoFnCNkfmXRyPXLjbKb
257231
* PATH: m/83696968'/32'/0'
258232
259233
OUTPUT
260234
* DERIVED ENTROPY=ead0b33988a616cf6a497f1c169d9e92562604e38305ccd3fc96f2252c177682
261-
* DERIVED XPRV=xprv9s21ZrQH143K4Px85utdpu6DFvY2NpHkJajPoupAznfiacH2MC9LasyW4uvqKXNxLWcjqGTbHKAhoZoMAbmRe5g9tAPA7cUUX4UVA1vFKFm
235+
* DERIVED XPRV=xprv9s21ZrQH143K2srSbCSg4m4kLvPMzcWydgmKEnMmoZUurYuBuYG46c6P71UGXMzmriLzCCBvKQWBUv3vPB3m1SATMhp3uEjXHJ42jFg7myX
262236
263237
===HEX===
264238
Application number: 128169'
@@ -311,7 +285,7 @@ INPUT:
311285
* PATH: m/83696968'/707764'/21'/0'
312286
313287
OUTPUT
314-
* DERIVED ENTROPY=74a2e87a9ba0cdd549bdd2f9ea880d554c6c355b08ed25088cfa88f3f1c4f74632b652fd4a8f5fda43074c6f6964a3753b08bb5210c8f5e75c07a4c2a20bf6e9
288+
* DERIVED ENTROPY=d7ad61d4a76575c5bad773feeb40299490b224e8e5df6c8ad8fe3d0a6eed7b85ead9fef7bcca8160f0ee48dc6e92b311fc71f2146623cc6952c03ce82c7b63fe
315289
* DERIVED PWD=dKLoepugzdVJvdL56ogNV
316290
317291
===PWD BASE85===
@@ -321,7 +295,7 @@ The derivation path format is: <code>m/83696968'/707785'/{pwd_len}'/{index}'</co
321295

322296
`10 <= pwd_len <= 80`
323297

324-
Base85 encode all 64 bytes of entropy.
298+
Base85 encode the all 64 bytes of entropy.
325299
Remove any spaces or new lines inserted by Base64 encoding process. Slice base85 result string
326300
on index 0 to `pwd_len`. This slice is the password. `pwd_len` is limited to 80 characters.
327301

@@ -352,40 +326,6 @@ OUTPUT
352326
* DERIVED ENTROPY=f7cfe56f63dca2490f65fcbf9ee63dcd85d18f751b6b5e1c1b8733af6459c904a75e82b4a22efff9b9e69de2144b293aa8714319a054b6cb55826a8e51425209
353327
* DERIVED PWD=_s`{TW89)i4`
354328
355-
===DICE===
356-
357-
Application number: 89101'
358-
359-
The derivation path format is: <code>m/83696968'/89101'/{sides}'/{rolls}'/{index}'</code>
360-
361-
2 <= sides <= 2^32 - 1
362-
1 <= rolls <= 2^32 - 1
363-
364-
Use this application to generate PIN numbers or any other numeric secret.
365-
Roll values are zero-indexed, such that an N-sided die produces values in the range
366-
<code>[0, N-1]</code>, inclusive. Applications should separate printed rolls by a comma or similar.
367-
368-
Create a BIP85 DRNG whose seed is the derived entropy.
369-
370-
Calculate the following integers:
371-
372-
bits_per_roll = ceil(log_2(sides))
373-
bytes_per_roll = ceil(bits_per_roll / 8)
374-
375-
Read <code>bytes_per_roll</code> bytes from the DRNG.
376-
Trim any bits in excess of <code>bits_per_roll</code> (retain the most
377-
significant bits). The resulting integer represents a single roll or trial.
378-
If the trial is greater than or equal to the number of sides, skip it and
379-
move on to the next one. Repeat as needed until all rolls are complete.
380-
381-
INPUT:
382-
* MASTER BIP32 ROOT KEY: xprv9s21ZrQH143K2LBWUUQRFXhucrQqBpKdRRxNVq2zBqsx8HVqFk2uYo8kmbaLLHRdqtQpUm98uKfu3vca1LqdGhUtyoFnCNkfmXRyPXLjbKb
383-
* PATH: m/83696968'/89101'/6'/10'/0'
384-
385-
OUTPUT
386-
* DERIVED ENTROPY=5e41f8f5d5d9ac09a20b8a5797a3172b28c806aead00d27e36609e2dd116a59176a738804236586f668da8a51b90c708a4226d7f92259c69f64c51124b6f6cd2
387-
* DERIVED ROLLS=1,0,0,2,0,1,5,5,2,4
388-
389329
===RSA===
390330

391331
Application number: 828365'
@@ -434,21 +374,9 @@ Many thanks to Peter Gray and Christopher Allen for their input, and to Peter fo
434374

435375
BIP32, BIP39
436376

437-
==Change Log==
438-
439-
* 1.0 (2020-07)
440-
* 2.0.0 (2024-09-22)
441-
* Swap chain code and private key bytes in application 32' for consistentcy with BIP-32 (major change)
442-
* Correct derived entropy for application 128169' test vector (major change)
443-
* Clarify big endian serialization
444-
* Add the Portuguese language (9') to application 39'
445-
* Add dice application 89101'
446-
* Clarify Testnet support for XPRV application 32'
447-
* Minor grammar, format, clarity improvements
448-
449377
==Footnotes==
450378

451-
<references />
379+
[1] There is a very small chance that you'll make an invalid key that is zero or bigger than the order of the curve. If this occurs, software should hard fail (forcing users to iterate to the next index).
452380

453381
From BIP32:
454382
In case parse<sub>256</sub>(I<sub>L</sub>) is 0 or ≥ n, the resulting key is invalid, and one should proceed with the next value for i. (Note: this has probability lower than 1 in 2<sup>127</sup>.)

0 commit comments

Comments
 (0)