Multisignature technology in bitcoin - math and code I am interested in the math and code behind bitcoin multisignature technology. I've been looking for actual code that creates a multisignature address/pub key, and verifies transactions/digital signatures; that can be executed in one go. I didn't find anything in bitcoin core maybe because I dont know where to look. Does anyone know where I can find the actual code that creates a multisignature adress and verifications. I would also like to know if there are any m of n schemes written in code and the math explanations behind adress /pub key creation and signature verification.
Multisig bitcoin transactions have a fairly simple implementation and don't require any advanced cryptography knowledge beyond the regular ECDSA used for P2PKH transactions. There are no "mutltisig address" or "multisig pubkey", but regular public keys and regular signatures are used. A multisig transaction output essentially contains a list of public keys with their count, and a threshold count which is &lt;= to the pubkey count, and finally the OP_CHECKMULTISIG(VERIFY) opcodes, which check the signatures provided against the public keys from the script.

In terms of creating multisig addresses, there are two RPC commands in Bitcoin Core. createmultisig and addmultisigaddress. The code behind the multisig script creation is in standard.cpp#GetScriptForMultisig, which is quite trivial.

Spending the multisig output is not quite as simple. You need to use the createrawtransaction command, followed by a call to signrawtransaction for each signature required to meet the threshold, and finally you can broadcast the signed transaction with sendrawtransaction.

As mentioned above, there is no standard address type for these transactions, but PSBT (Partially Signed Bitcoin Transactions), also known as BIP-174 defines a standard serialization and textual encoding (in Base64) which can be used for sharing the raw transaction at each point in the above process with other parties if the private keys are not owned by the same user.

There are proposals for doing mutlisig schemes in other ways which utilize key or signature aggregation. None of these have a concrete proposal in the form of a BIP yet. I suggest reading the MuSig paper from Maxwell et al. as a starting point, and have a look at BIP-340, which defines the Schnorr Signature scheme which is likely to be made standard into Bitcoin at some point in the near future. Note that the proposal for OP_CHECKSIGADD in BIP-342 does not by itself allow for key or signature aggregation, but it does allow for more efficient batch verification of multiple signatures.