<div dir="ltr"><div>Hi all,</div><div><br></div>Hugo and I have discussed off-list, and I have two concerns with this proposal:<div><br></div><div>1. I believe adding the TOKEN and encryption to the exchange adds complexity to already notoriously complex multisig, without adding much in the way of security. This is because the shared secret (TOKEN) must still be shared securely, and if you have established an (off-protocol) secure channel to do this, why not just share the actual multisig configuration data directly in that channel? If you are able to do so, you retain the advantage of being able to inspect the data directly.</div><div><br></div><div>2. Asking the user to enter the derivation into the Signer also adds (IMO unnecessary) complexity to the multisig setup process. A different way of doing it, which is specified in the UR crypto-account format linked to previously, has the Signer provide as many common derivations (along with their xpubs) as it can support for a given BIP44 account number. This has the dual advantage of making things simpler for the user (they only have to provide an optional account number) and increasing the standardisation on common derivation paths. On receiving these derivation/xpub pairs, the Coordinator can simply pick the appropriate one.</div><div><br></div><div>These concerns noted, I agree it's a good idea to have Signers save the multisig configuration as proposed, and it would be great to have standardisation in hww import and export formats (not just for multisig). On that note, I'd love to see greater adoption of the efficient UR2.0 standard and associated formats for airgapped data transmission using QR codes.</div><div><br></div><div>Craig</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 15, 2021 at 11:13 AM Hugo Nguyen via bitcoin-dev <<a href="mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@lists.linuxfoundation.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all,<br>I have updated the proposal based on further feedback. The new spec is included at the bottom.</div><div><br></div><div>I have also created a public Github PR to make it easier to comment on the text of the spec itself: <a href="https://github.com/nunchuk-io/bips/pull/1" target="_blank">https://github.com/nunchuk-io/bips/pull/1</a> .<br><br>Could someone please let me know what else needs to be done before a BIP number can be assigned?<br><br><br>=== Quick summary of changes from last update ===<br><br>1. Define encryption modes<br><br># NO_ENCRYPTION: Encryption is disabled.<br># STANDARD : the TOKEN is a 64-bit nonce.<br># EXTENDED : the TOKEN is a 128-bit nonce.<br><br>2. Define signature algorithm<br><br>Follow BIP-0322, legacy format allowed.<br><br>3. Multiple TOKENs (optional)<br><br>Also add an option where the Coordinator can choose to use one common TOKEN for all Signers, or use one per Signer.<br><br>=== End of summary ===</div><div><br></div><div><br>Cheers,<br>Hugo</div><div class="gmail_quote"><div><br><br><pre><br>  BIP: To be determined<br>  Layer: Applications<br>  Title: Bitcoin Secure Multisig Setup (BSMS)<br>  Author: Hugo Nguyen <hugo at <a href="http://nunchuk.io" target="_blank">nunchuk.io</a>>, Peter Gray <peter at <a href="http://coinkite.com" target="_blank">coinkite.com</a>>, Marko Bencun <marko at <a href="http://shiftcrypto.ch" target="_blank">shiftcrypto.ch</a>>, Pavol Rusnak <<a href="mailto:stick@satoshilabs.com" target="_blank">stick@satoshilabs.com</a>>, Aaron Chen <aarondongchen at <a href="http://gmail.com" target="_blank">gmail.com</a>>, Rodolfo Novak <rodolfo at <a href="http://coinkite.com" target="_blank">coinkite.com</a>><br>  Comments-Summary: No comments yet.<br>  Comments-URI:<br>  Status: Proposed<br>  Type: Standards Track<br>  Created: 2020-11-10<br>  License: BSD-2-Clause<br></pre><br><br>==Introduction==<br><br>===Abstract===<br><br>This document proposes a mechanism to set up multisig wallets securely.<br><br>===Copyright===<br><br>This BIP is licensed under the 2-clause BSD license.<br><br>===Motivation===<br><br>The Bitcoin multisig experience has been greatly streamlined under [<a href="https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki" target="_blank">https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki</a> BIP-0174<br>(Partially Signed Bitcoin Transaction)]. However, what is still missing is a standardized process for setting up multisig wallets securely across different vendors.<br><br>There are a number of concerns when it comes to setting up a multisig wallet:<br><br># Whether the multisig configuration, such as Signer membership, script type, derivation paths and number of signatures required, is correct and not tampered with.<br># Whether Signer persists the multisig configuration in their respective storage, and under what format.<br># Whether Signer's storage is tamper-proof.<br># Whether Signer subsequently uses the multisig configuration to generate and verify receive and change addresses.<br><br>An attacker who can modify the multisig configuration can steal or hold funds to ransom by duping the user into sending funds to the wrong address.<br><br>This proposal seeks to address concerns #1 and #2: to mitigate the risk of tampering during the initial setup phase, and to define an interoperable multisig configuration format.<br><br>Concerns #3 and #4 should be handled by Signers and is out of scope of this proposal.<br><br>==Specification==<br><br>===Prerequisites===<br>This proposal assumes the parties in the multisig support [<a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki</a> BIP-0032], [<a href="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md" target="_blank">https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md</a> the descriptor language] and encryption.<br><br>===Roles===<br>====Coordinator====<br><br>The Coordinator initiates the multisig setup. The Coordinator determines what type of multisig is used and the exact policy script. If encryption is enabled, the Coordinator also distributes a shared secret or shared secrets to the parties involved for secure communication. The Coordinator gathers information from the Signers to generate a descriptor record. The Coordinator distributes the descriptor record back to the Signers.<br><br>====Signer====<br><br>The Signer is a participating member in the multisig. Its responsibilities include providing its key record -- which contains an Extended Public Key (XPUB) -- to the Coordinator, verifying that its XPUB is included in the descriptor record and persisting the descriptor record in its storage.<br><br>===Setup Process===<br><br>====Round 1====<br><br>=====Coordinator=====<br><br>* The Coordinator creates a multisig wallet creation session. The Coordinator constructs the multisig script and its policy parameters, such as the total number of signers and the required number of signatures (<tt>M</tt> and <tt>N</tt>).<br>* The session should expire after some time period determined by the Coordinator, e.g., 24 hours.<br>* If encryption is enabled, the Coordinator distributes a secret <tt>TOKEN</tt> to each Signer over a secure channel. The Signer can use the <tt>TOKEN</tt> to derive an <tt>ENCRYPTION_KEY</tt>. Refer to the Encryption section below for details on the <tt>TOKEN</tt>, the key derivation function and the encryption scheme. Depending on the use case, the Coordinator can decide whether to share one common <tt>TOKEN</tt> for all Signers, or to have one per Signer.<br>* If encryption is disabled, <tt>TOKEN</tt> is set to <tt>0</tt>, and all the encryption/decryption steps below can be skipped.<br><br>=====Signer=====<br><br>* The Signer initiates a new secure multisig setup session by setting the <tt>TOKEN</tt>. The Signer derives an <tt>ENCRYPTION_KEY</tt> from the <tt>TOKEN</tt>. The Signer can keep the session open until a different value for the <tt>TOKEN</tt> is set.<br>* The Signer generates a key record by prompting the user for a multisig derivation path and retrieves the XPUB at that derivation path. Optionally, the Signer can choose a path on behalf of the user. If the Signer chooses the path, it should try to avoid reusing XPUBs for different wallets.<br>* The first line in the record must be the <tt>TOKEN</tt>. The second line must be the <tt>KEY</tt>. The <tt>KEY</tt> is an XPUB plus its key origin information, written in the descriptor-defined format, i.e.: <tt>[{master key fingerprint}/{derivation path}]{XPUB}</tt>. The third line must be a <tt>SIG</tt>, whereas <tt>SIG</tt> is the signature generated by using the private key associated with the XPUB to sign the first two lines.  The signature should follow [<a href="https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki" target="_blank">https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki</a> BIP-0322], legacy format accepted. Finally, the Signer encrypts the entire record with <tt>ENCRYPTION_KEY</tt>.<br><br>====Round 2====<br><br>=====Coordinator=====<br><br>* The Coordinator gathers key records from all participating Signers. Abort the setup if the wallet setup session has expired.<br>* For each key record, the Coordinator decrypts it using <tt>ENCRYPTION_KEY</tt>. The Coordinator verifies that the included <tt>SIG</tt> is valid given the <tt>KEY</tt>.<br>* If all key records look good, the Coordinator fills in all necessary information to generate a descriptor record, which is simply the descriptor string plus a <tt>CHECKSUM</tt>, all in one line. The <tt>CHECKSUM</tt> has [<a href="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md#checksums" target="_blank">https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md#checksums</a> BECH32 encoding].<br>* The Coordinator encrypts this descriptor record with <tt>ENCRYPTION_KEY</tt>.<br>* The Coordinator sends the encrypted descriptor record to all participating Signers.<br><br>=====Signer=====<br><br>* The Signer imports the descriptor record, decrypts it using the <tt>ENCRYPTION_KEY</tt> derived from the open session.<br>* The Signer calculates and verifies the descriptor’s <tt>CHECKSUM</tt>. Abort the setup if the <tt>CHECKSUM</tt> is incorrect.<br>* The Signer checks whether one of the <tt>KEY</tt>s in the descriptor belongs to it, using path and fingerprint information included in the descriptor. The check must perform an exact match on the <tt>KEY</tt>s, and not using shortcuts such as matching fingerprints (which is trivial to spoof). Abort the setup if it doesn’t detect its own <tt>KEY</tt>.<br>* For confirmation, the Signer must display to the user the <tt>CHECKSUM</tt>, plus other configurations, such as <tt>M</tt> and <tt>N</tt>. The total number of Signers, <tt>N</tt>, is important to prevent a <tt>KEY</tt> insertion attack. All participating Signers should be able to display the same confirmation.<br>* If all checks pass, the Signer persists the descriptor record in its storage.<br>* The Signer can choose to further restrict post-XPUB derivation paths, such as to those defined in [<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki</a> BIP-0044].<br>* The Signer should subsequently use the descriptor to generate and verify receive and change addresses.<br><br>This completes the setup.<br><br>===Encryption===<br><br>====The Token====<br>We define three modes of encryption.<br><br># <tt>NO_ENCRYPTION</tt> : the <tt>TOKEN</tt> is set to <tt>0</tt>. Encryption is disabled.<br># <tt>STANDARD</tt> : the <tt>TOKEN</tt> is a 64-bit nonce.<br># <tt>EXTENDED</tt> : the <tt>TOKEN</tt> is a 128-bit nonce.<br><br>The <tt>TOKEN</tt> can be converted to one of these formats:<br>* A mnemonic phrase using [<a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki</a> BIP-0039] word list (6 words in <tt>STANDARD</tt> mode, 12 words in <tt>EXTENDED</tt> mode)<br>* A decimal number (20 digits in <tt>STANDARD</tt> mode, 40 digits in <tt>EXTENDED</tt> mode)<br>* A QR code<br>* Other formats<br><br>The flexibility in the data format allows each Signer to customize the User Experience based on its respective capabilities.<br><br>====Key Derivation====<br>The key derivation function is [<a href="https://tools.ietf.org/html/rfc2898" target="_blank">https://tools.ietf.org/html/rfc2898</a> PBKDF2], with PRF = SHA512. Specifically:<br><br><tt>DK = PBKDF2(PRF, Password, Salt, c, dkLen)</tt><br><br>Whereas:<br><br>* PRF = <tt>SHA512</tt><br>* Password = <tt>"No SPOF"</tt><br>* Salt = <tt>TOKEN</tt><br>* c = <tt>2048</tt><br>* dkLen = <tt>256</tt><br>* DK = Derived <tt>ENCRYPTION_KEY</tt><br><br>====Encryption Scheme====<br>The encryption scheme is [<a href="https://tools.ietf.org/html/rfc3686" target="_blank">https://tools.ietf.org/html/rfc3686</a> AES, CTR mode].<br><br>==QR Codes==<br>For signers that use QR codes to transmit data, key and descriptor records can be converted to QR codes, following [<a href="https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md" target="_blank">https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md</a> the BCR standard].<br><br>Also refer to [<a href="https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-015-account.md" target="_blank">https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-015-account.md</a> UR Type Definition for BIP44 Accounts] and [<a href="https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-010-output-desc.md" target="_blank">https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-010-output-desc.md</a> UR Type Definition for Bitcoin Output Descriptors] for more details.<br><br>==Security==<br><br>This proposal introduces two layers of protection. The first one is a temporary, secret token, used to encrypt the two rounds of communication between the Signer and the Coordinator. The second one is through the descriptor checksum and visual inspection of the descriptor itself.<br><br>The token is only needed during the setup phase, and can be safely thrown away afterwards. The token does not guarantee that the Signer membership set is not modified, since that depends on the overall security of all parties in the setup, but it can make it significantly harder for an attacker to do so.<br><br>There are three ways an attacker can modify the membership set: by changing an existing member, by removing an existing member, or by adding a new member.<br><br>For the first two methods, one of the Signers will be able to detect that its membership has been changed or removed, and reject the final descriptor. Thus, it is vital that all participating Signers check that their membership is intact in the descriptor. Even one Signer failing to check for its membership means that the setup could be compromised.<br><br>For the third type of attack, the descriptor checksum and visual inspection of the descriptor itself are the only way to guard against malicious members from being inserted into the set.<br><br>==Acknowledgement==<br><br>Special thanks to Dmitry Petukhov, Christopher Allen, Craig Raw and others for their feedback on the specification.<br><br>==References==<br><br>Original mailing list thread: <a href="https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-February/018385.html" target="_blank">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-February/018385.html</a><br><br> </div></div></div>
_______________________________________________<br>
bitcoin-dev mailing list<br>
<a href="mailto:bitcoin-dev@lists.linuxfoundation.org" target="_blank">bitcoin-dev@lists.linuxfoundation.org</a><br>
<a href="https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" rel="noreferrer" target="_blank">https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev</a><br>
</blockquote></div>