Multisignature in stellar blockchain
Published: 2022-07-12 21:26:25



Signatures are required to authorize operations and to authorize changes to the source account,
Transaction signatures are created by cryptographically signing the transaction object contents with a secret key. Stellar currently uses the ed25519 signature scheme, but there's also a mechanism for adding additional types of public/private key schemes. A transaction with an attached signature is considered to have authorization from that public key.
Multisignature - is useful to add extra security to an account and power
a transaction that may need more than one signature. If the transaction has operations that affect more than one account, it will need authorization from every account in question. A transaction will also need additional signatures if the account associated with the transaction has multiple public keys. [More details](https://developers.stellar.org/docs/glossary/multisig/#thresholds)


### What is stellar threshold 

Is the amount of signature weight required to authorize an operation, threshold has 3 levels which are low, medium, or high, threshold for a given level can be set to any number from 0–255

How it works

Consider the table below on how to  set threshold


<table>
  <tr>
   <td><strong>Level</strong>
   </td>
   <td><strong>Operations</strong>
   </td>
   <td><strong>Number</strong>
   </td>
  </tr>
  <tr>
   <td>Low
   </td>
   <td>
<ul>

<li>Trusting Processing

<li>Allow trust and & Set Trustline Flag

<li>Bump Sequence
</li>
</ul>
   </td>
   <td>
    1
   </td>
  </tr>
  <tr>
   <td>Medium 
   </td>
   <td>
<ul>

<li>All other <a href="https://developers.stellar.org/docs/start/list-of-operations/#content">Operations</a>
</li>
</ul>
   </td>
   <td>
    2
   </td>
  </tr>
  <tr>
   <td>High
   </td>
   <td>
<ul>

<li>High security

<li>Set options

<li>Account Merge 
</li>
</ul>
   </td>
   <td>
    3
   </td>
  </tr>
</table>


Above table show levels, Operation and Numbers  
For Low level operations any account can sign  and   make transactions

For Medium level -> it required two signers with Low level to authorize operation , and only one signer with medium level or High level

For High level operation -> can authorize any transaction


###   How to  set threshold to  stellar new stellar account

Note that when your create an account for the first time the operations thresholds (low/medium/high) are 0/0/0 and there's no signer's list.

There are many way you can set threshold depend on what you intend the blockchain to do , example will be as for Anchors

 Consider we have account which is our Anchor account lets call it Operation account

And will will give it a power to have control over all other accounts this means as Anchor we can be able to handle every transaction is something went wrong and we are going to give Operation account threshold of 3 weight as higher

And for other accounts let call them customer accounts will give them 2 weight of threshold as medium level 

Also the low threshold will be 1 weight 

See the code snippet below 






![alt_text](https://res.cloudinary.com/clickpesa/image/upload/v1657659061/registration/images/ap0a5htrhbnxp48gulaf.png "image_tooltip")


 

As you can see we use the [setOptions](https://developers.stellar.org/docs/start/list-of-operations/#set-options) which Sets options for an account, such as setting the inflation destination or adding an additional signer on an account

You can see we set medThreshold with 2 weight and masterWeight with 2

And we added signer which is our Operation account and give weight of 3

For the case of normal transactions any account can do, but for the high operation it will required Operation account to sign that transaction 

How to sign to a such transaction 




![alt_text](https://res.cloudinary.com/clickpesa/image/upload/v1657659264/registration/images/sm8b1oxdfqwlyzflbh95.png "image_tooltip")


Let use our example to see issue when setup doesn’t configured well

What will happen if  we set the threshold and we didnt specify the signer :)




![alt_text](https://res.cloudinary.com/clickpesa/image/upload/v1657659351/registration/images/e8sd7uhbgoecasfxpixx.png "image_tooltip")


It means any account can be used to sign to perform any transaction since each account has 2 weight and to perform a higher operation 1 weight is missing so any account can sign and make 4 weight which is greater than 3

There are more [example](https://developers.stellar.org/docs/glossary/multisig/#example-1:-anchors) on how to configure threshold and experience the power of blockchain