<oembed><type>rich</type><version>1.0</version><author_name>npub1ldnkgsksgfdvdzn3e2fgdtdxudrsl35qu3jfup0h2kwrxhg2477sddfrax</author_name><author_url>https://nostr.ae/npub1ldnkgsksgfdvdzn3e2fgdtdxudrsl35qu3jfup0h2kwrxhg2477sddfrax</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2014-04-25&#xA;📝 Original message:Hi, I&#39;m part of the team building copay &lt;https://github.com/bitpay/copay&gt;,&#xA;a multisignature P2SH HD wallet. We&#39;ve been following the discussion&#xA;regarding standardizing the structure for branches both on this list and on&#xA;github (1 &lt;https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki&gt;,&#xA;2 &lt;https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki&gt;,&#xA;3&lt;https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki&gt;,&#xA;4 &lt;https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki&gt;,&#xA;5&lt;https://github.com/bitcoin/bips/pull/52&gt;).&#xA;Soon, we realized the assumptions in the discussions were not true for a&#xA;multisig hd wallet, so we wanted to share our current approach to that, to&#xA;get feedback and see if we can arrive to a new standard (and possibly a new&#xA;BIP)&#xA;&#xA;These are our assumptions:&#xA; - N parties want to share an m-of-n wallet.&#xA; - Each party must generate their master private keys independently.&#xA; - Use multisig P2SH for all addresses.&#xA; - Use BIP32 to derive public keys, then create a multisig script, and use&#xA;the P2SH address for that.&#xA; - The address generation process should not require communicating with&#xA;other parties. (Thus, all parties must be able to generate all public keys)&#xA; - Transaction creation + signing requires communication between parties,&#xA;of course.&#xA;&#xA;-------------------------------------------------&#xA;&#xA;Following BIP43, we&#39;re be using:&#xA;&#xA;&#xA;m / purpose&#39; / *&#xA;&#xA;where *purpose* is the hardened derivation scheme based on the new BIP&#xA;number.&#xA;We then define the following levels:&#xA;&#xA;&#xA;m / purpose&#39; / cosigner_index / change / address_index&#xA;&#xA;Each level has a special meaning detailed below:&#xA;&#xA;*cosigner_index* &lt;http://en.wikipedia.org/wiki/Co-signing&gt;: the index of&#xA;the party creating this address. The indices can be determined&#xA;independently by lexicographically sorting the master public keys of each&#xA;cosigner.&#xA;&#xA;*change*: 0 for change, 1 for receive address.&#xA;&#xA;*address_index*: Addresses are numbered from index 0 in sequentially&#xA;increasing manner. We&#39;re currently syncing the max used index for each&#xA;branch between all parties when they connect, but we&#39;re open to considering&#xA;removing the index sync and doing the more elegant used-address discovery&#xA;via a gap limit, as discussed in&#xA;BIP44&lt;https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#address-gap-limit&gt;.&#xA;We feel 20 might be too low though.&#xA;&#xA;*Wallet high-level description:*&#xA;Each party generates their own extended master keypair and shares the&#xA;extended purpose&#39; public key with the others, which is stored encrypted.&#xA;Each party can generate any of the other&#39;s derived public keys, but only&#xA;his own private keys.&#xA;&#xA;*General address generation procedure:*&#xA;When generating an address, each party can independently generate the N&#xA;needed public keys. They do this by deriving the public key in each of the&#xA;different trees, but using the same path. They can then generate the&#xA;multisig script and the corresponding p2sh address. In this way, each path&#xA;corresponds to an address, but the public keys for that address come from&#xA;different trees.&#xA;&#xA;*Receive address case:*&#xA;Each cosigner generates addresses only on his own branch. One of the n&#xA;cosigners wants to receive a payment, and the others are offline. He knows&#xA;the last used index in his own branch, because only he generates addresses&#xA;there. Thus, he can generate the public keys for all of the others using&#xA;the next index, and calculate the needed script for the address.&#xA;&#xA;*Example: *Cosigner #2 wants to receive a payment to the shared wallet. His&#xA;last used index on his own branch is 4. Then, the path for the next receive&#xA;address is m/$purpose/2/1/5. He uses this same path in all of the cosigners&#xA;trees to generate a public key for each one, and from that he gets the new&#xA;p2sh address.&#xA;&#xA;*Change address case:*&#xA;Again, each cosigner generates addresses only on his own branch. One of the&#xA;n cosigners wants to create an outgoing payment, for which he&#39;ll need a&#xA;change address. He generates a new address using the same procedure as&#xA;above, but using a separate index to track the used change addresses.&#xA;&#xA;*Example: *Cosigner #5 wants to send a payment from the shared wallet, for&#xA;which he&#39;ll need a change address. His last used change index on his own&#xA;branch is 11. Then, the path for the next change address is&#xA;m/$purpose/5/0/12. He uses this same path in all of the cosigners trees to&#xA;generate a public key for each one, and from that he gets the new p2sh&#xA;address.&#xA;&#xA;&#xA;*Transaction creation and signing:*&#xA;When creating a transaction, first one of the parties creates a Transaction&#xA;Proposal. This is a transaction that spends some output stored in any of&#xA;the p2sh multisig addresses (corresponding to any of the copayers&#39;&#xA;branches). This proposal is sent to the other parties, who decide if they&#xA;want to sign. If they approve the proposal, they can generate their needed&#xA;private key for that specific address (using the same path that generated&#xA;the public key in that address, but deriving the private key instead), and&#xA;sign it. Once the proposal reaches m signatures, any cosigner can broadcast&#xA;it to the network, becoming final. The specifics of how this proposal is&#xA;structured, and the protocol to accept or reject it, belong to another BIP,&#xA;in my opinion.&#xA;&#xA;*Final comments:*&#xA;- We&#39;re currently lexicographically sorting the public keys for each&#xA;address separately. We&#39;ve read Mike Belshe&#39;s comments about sorting the&#xA;master public keys and then using the same order for all derived addresses,&#xA;but we couldn&#39;t think of any benefits of doing that (I mean, the benefits&#xA;of knowing whose public key is which).&#xA;- We originally thought we would need a non-hardened version of purpose for&#xA;the path, because we needed every party to be able to generate all the&#xA;public keys of the others. With the proposed path, is it true that the&#xA;cosigners will be able to generate them, by knowing the extended purpose&#xA;public key for each copayer? (m/purpose&#39;)&#xA;- The reason for using separate branches for each cosigner is we don&#39;t want&#xA;two of them generating the same address and receiving simultaneous payments&#xA;to it. The ideal case is that each address receives at most one payment,&#xA;requested by the corresponding cosigner.&#xA;&#xA;&#xA;Thoughts?&#xA;Manuel&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20140425/65b0a04c/attachment.html&gt;</html></oembed>