Page Content

Tutorials

P2MS Bitcoin: The Basics Of Collaborative Fund Management

Pay-to-MultiSig P2MS

P2MS
P2MS

A key kind of Bitcoin transaction known as Pay-to-MultiSig (P2MS), or simply Multisignature, requires several digital signatures in order to approve the expenditure of bitcoins. P2MS enables funds to be managed by a group of private keys, requiring a predetermined number of them to sign in order to unlock the funds, in contrast to ordinary transactions that normally just require one signature. It is a fundamental idea for developing shared wallets and more complex blockchain behaviours akin to smart contracts.

Core Concept: M-of-N Multisignature

The foundation of P2MS transactions is the M-of-N multisignature principle:

  • M: Represents the bare minimum of signatures needed to release the money.
  • N: Indicates how many public keys are used in the multisignature system overall.

A 2-of-3 multisig transaction, for instance, requires the signature of any two of the three designated participants in order to spend the locked cash.

How P2MS Transactions Work

Like other transaction types, a P2MS transaction is processed by two primary scripts:

The Locking Script (scriptPubKey):

  • Using a scriptPubKey that specifies the multisignature criteria, the sender generates a transaction output.
  • It contains all N of the public keys involved as well as the M and N values.
  • M <Public Key 1> <Public Key 2> … <Public Key N> N OP_CHECKMULTISIG

Now let’s dissect the opcodes:

  • M: An opcode is a number that indicates the bare minimum of signatures needed.
  • <Public Key 1> ... <Public Key N>: A list of every public key that is available for use in signing.
  • N: The total number of public keys is indicated by a number (opcode).
  • OP_CHECKMULTISIG: The important opcode is this. To determine whether at least M of the N signatures on the stack are legitimate, it compares them to the public keys.

The scriptSig (unlocking script):

  • The necessary M parties must sign a new transaction in order to spend the money.
  • The recipient generates the required signatures in an unlocking script.

 OP_0 <Signature 1> <Signature 2> … <Signature M>

  • OP_0: This is a peculiarity of the opcode OP_CHECKMULTISIG. The opcode removes an extra item from the stack before validating signatures because of a problem or design decision in the original implementation. A solution to take this into consideration and guarantee that the script executes properly is the OP_0.
  • <Signature 1> ... <Signature M>: The necessary M parties’ digital signatures.

Verification

  • The two scripts are combined when a network node validates the transaction.
  • On receiving the public keys and signatures, the OP_CHECKMULTISIG opcode performs cryptographic checks and confirms that the required number of signatures are valid.
  • OP_CHECKMULTISIG pushes an OP_1 into the stack and validates the transaction if M valid signatures are found.

Use Cases and Advantages of P2MS

P2MS transactions provide a number of significant benefits and uses for digital asset management, including:

Shared Wallets and Joint Accounts: This is a typical use case that enables cooperative fund management by several users. For instance, a couple can utilize a 2-of-2 multisig wallet, which requires both signers for every transaction. Under a “1-of-2” model, a payment could be approved by either of the two joint account holders.

Increased Security: Multisig wallets reduce the possibility of unwanted removal and lessen the single point of failure that comes with using only one private key by needing many private keys in order to send money. A person can safeguard money, for example, by requiring two out of three signatures from private keys kept on separate devices. This way, even if one device is compromised, the money is safe.

Escrow Services: A buyer, seller, and an impartial third-party arbitrator can employ a 2-of-3 multisig for a trustless escrow service. Money is sent to two out of three addresses. Both the buyer and the seller sign to release payments if the buyer is happy. The arbiter may sign with either party to settle a disagreement.

Corporate and Board Accounts: Businesses can improve internal controls and avoid a single point of failure by using multisig to need approval from several executives or board members for significant transactions.

Transparency and Auditability: Multisignature wallets have been used by entities conducting Initial Coin Offerings (ICOs) to gather cash. These entities frequently make their wallet code accessible and publicly share the authorized addresses, allowing investors to audit funds and boosting trust.

Limitations and the Rise of P2SH

Notwithstanding its strength, raw P2MS has a number of drawbacks that have rendered it obsolete for the majority of direct uses and prompted the creation of substitutes:

Long and Complex Addresses / No Address Format: A straightforward, human-readable address cannot adequately capture the complexity of the original P2MS script. Most wallets only permit transactions via addresses, not raw scripts, thus sharing the complete script is required in order to receive funds.

Blockchain Bloat / Larger Transaction Size: Larger transaction sizes and possibly higher fees result from the blockchain storing the entire P2MS script, which contains all of the public keys. This can be ineffective, particularly when there are a lot of public keys.

Limited Number of Public Keys (N): A typical P2MS script can only use a maximum of three public keys, even if OP_CHECKMULTISIG is technically valid for up to twenty (due to policy requirements preventing excessive data in the UTXO set and non-relay by nodes).

Reduced Privacy: On-chain visibility of the public keys and the quantity of necessary signatures diminishes privacy.

Legacy Script: P2MS is rarely found directly on blockchain outputs and is regarded as an outdated or old script pattern for direct use.

Due to these restrictions, Pay-to-Script-Hash (P2SH) and later Pay-to-Witness-Script-Hash (P2WSH) with Segregated Witness were developed. These are currently the recommended methods for implementing multisig. Similar to a P2PKH address, P2SH addresses enable the multisig conditions to be represented by a brief, straightforward hash, whilst the intricate script is only exposed once the money has been spent. While maintaining access to the robust P2MS logic at its core, this improves multisig’s usability and performance while providing improved privacy. Both scripts exist because P2MS became a standard script in January 2012 (BIP 11) and P2SH became a standard script in April 2012 (BIP 16).

Beyond Bitcoin

Blockchain technology is based on multisignature concepts, which are not exclusive to Bitcoin. For instance:

  • Ethereum facilitates the use of multisignature wallets, which are often implemented as smart contracts and enable the distribution of control across a team or the management of assets between devices.
  • There are several multisignature schemes that combine private view keys and public spend keys, including N/N and (N-1)/N schemes.
  • Compared to Schnorr multisignatures, BLS multisignatures are a more recent cryptographic primitive that can merge several separate signatures into a single, smaller signature, possibly lowering transaction size and communication rounds.
  • Multisignature methods are also used by other blockchains like Openchain and Multichain.

Summary Table

FeatureP2MS
MeaningPay-to-MultiSignature
Funds locked toA group of public keys and a minimum m signatures
Use caseJoint accounts, escrow, enhanced security
Script typeSpecifies m, n, and n public keys
AdvantagesMulti-party security, flexibility
DisadvantagesLarger size, less privacy, higher fees
Still used?Rarely as raw P2MS — usually wrapped in P2SH
Index