Multisignature in stellar blockchain

Geofrey Bundala
ClickPesa Engineering Blog
3 min readJul 12, 2022

Signatures are required to authorize operations and 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 the 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 the threshold

The 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 a Low level to authorize operation and only one signer with a medium level or High level

For High level operation, -> can authorize any transaction

How to set the threshold to stellar new stellar account

Note that when you 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 ways you can set a threshold depending on what you intend the blockchain to do, an example will be as Anchors

Consider we have an account which is our Anchor account let's call it the Operation account

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

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

Also, the low threshold will be 1 weight

See the code snippet below

As you can see we use the setOptions which Set 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 weights and masterWeight with 2

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

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

How to sign a such transaction

Let's use our example to see issues when the setup doesn’t configure well

What will happen if we set the threshold and we didn't specify the signer :)

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

Originally published at https://dev.to on July 12, 2022.

--

--