DEV Community

Geofrey Bundala for ClickPesa

Posted on

Multisignature in stellar blockchain

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

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

Level Operations Number
Low
  • Trusting Processing
  • Allow trust and & Set Trustline Flag
  • Bump Sequence
1
Medium 2
High
  • High security
  • Set options
  • Account Merge
3

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

As you can see we use the setOptions 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

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

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 on how to configure threshold and experience the power of blockchain

Top comments (0)