Multisignature

One of the most widely used example of P2SH is multisignature, where a specific number of pre-specified signatures are required to unlock a UTXO.

A typical multisig scheme is an m-of-n, where you need m of n signatures users to sign off on a transaction before it is considered valid.

Some unique benefits of multisig are…First, multisig scheme increases the difficulty of stealing funds.

Instead of using one private key to unlock the fund, the thief now has to have the minimum number of keys that satisfies the multisignature requirements.

Second, using multiple keys to unlock accounts prevents losses.

Before using multisig, losing the one and only bitcoin private key would be an end-all-be-all situation.

Now, with a 2-of-4 address, for example, you can still redeem the funds within the address by only having to provide signatures from 2 keys.

Thirdly, it can also be used to give control of a single address to multiple people.

For instance, the executive board of a company can mandate that 3 out of 5 executives must approve of a budget before a fund can be spent, and using a 3-of-5 signature suits the exact purpose.

Let’s take a look at the diagram on the slide to see how a multisignature script is constructed and executed.

In the first box of the left hand side diagram, you see the unlocking script, which contains a number of signatures that are just enough to satisfy the conditions of the locking script which allows the user to spend the UTXO.

Below the unlocking script is the redeeming script, which contains all possible and eligible signatures to spending the bitcoins.

It sets the rules on how and who can spend money from a particular account.

The letter m on the top of the box represents the minimum number of signatures, and the letter n shows the total number of valid signatures.

This redeeming script is only revealed and used when the redeemer wants to spend the money.

The redeeming script is then hashed, to check against the redeeming script hash, and evaluated.

Lastly, if you look at the bottom of the diagram, the locking script contains the hash against which the hash of the redeem script will later be compared with.

For a multisig transaction to be valid, the full redeem script is hashed and then compared with the script hash.

If they match, the UTXO is unlocked.

Timelocks