Bitcoin Forum
June 14, 2024, 07:27:58 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Child key derivation function  (Read 1282 times)
rupy (OP)
Hero Member
*****
Offline Offline

Activity: 725
Merit: 500



View Profile
November 11, 2014, 05:45:52 PM
Last edit: November 11, 2014, 08:14:23 PM by rupy
 #1

Is there any way to generate keys from a key in such a way that you can proove that the first key owns the "child" keys?

String child = generateChild("xPNmJTt8WEGufQyg");

//Where child is a potentially* unique secure pseudo random key.

boolean valid = validChild("xPNmJTt8WEGufQyg", child);

//Where valid == true...

Edit: I could solve this with a simple unique "primary key" hash:

String primary = "email | username | userid";

String child = SHA(primary + "xPNmJTt8WEGufQyg");

boolean valid = child.equals(SHA(primary + "xPNmJTt8WEGufQyg"));


Actually no I can't as the keys might collide and I need random uniqueness. Undecided

* If it collides I need to be able to just generate another.

BANKBOOK GWT Wallet & no-FIAT Billing API
ffe
Sr. Member
****
Offline Offline

Activity: 308
Merit: 250



View Profile
November 11, 2014, 07:53:18 PM
 #2

Look at how BIP0032 does it.

https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
rupy (OP)
Hero Member
*****
Offline Offline

Activity: 725
Merit: 500



View Profile
November 11, 2014, 08:33:52 PM
Last edit: November 11, 2014, 09:07:19 PM by rupy
 #3

Ok, so that follows my primary key hash concat logic that i striked out in OP (only BIP-32 calls it index, or sequence here), but then I need to store that index/sequence next to my child key... also I need to make sure the index/sequence is used only once too! hm, was looking for something cleaner.

Thx!

BANKBOOK GWT Wallet & no-FIAT Billing API
ffe
Sr. Member
****
Offline Offline

Activity: 308
Merit: 250



View Profile
November 11, 2014, 09:06:40 PM
 #4

Ok, so that follows my primary key hash concat logic that i striked out in OP (only BIP-32 calls it index, or sequence here), but then I need to store that index/sequence next to my child key... also I need to make sure the index/sequence is used only once too! hm, was looking for something cleaner.

Thx!

Depending on how many child keys you want you could search for child keys where the index is encoded in the bits of the child key. No need to store the index with the child key.

Most child keys would not have this property, but those that do are obviously children of the master key. You extract the index from the child key and re-derive the child key from the master key.

For example you could start generating child keys with index i starting at 1 and going up. The first few bits of the hash of the child key could be compared to i. If it matches, this is a usable child key.

Unfortunately, you'd be lucky to find a key with this property. You can increase the probability of finding a child key if you allow yourself more child key candidates per index. You could hash n times for example and if the first few bits of any of those hashes matches i you have a usable child key. Of course you have to check possibly all n candidate indexes to show that the child is derived from the master.

Probably too complicated for your application, but then, I don't know your application.


dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
November 12, 2014, 12:50:49 PM
 #5

then I need to store that index/sequence next to my child key... also I need to make sure the index/sequence is used only once too!

The extended private key (starts with xprv) contains all that information, including a fingerprint of the parent.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!