🚀
Stellar Kickstart
  • 🏕️Welcome to the SCF Kickstart Week
    • 💰Funding Overview
    • ✍️Dear changemakers, visionaries, and problem solvers
    • ℹ️TL;DR: How to Maximize Your SCF Kickstart Week Experience
  • 📚Fundamentals of Integrating with Stellar
    • 🚀Stellar For
    • 🏗️Building with Stellar
    • 🔧Tools
    • 👷Resources
      • Fundamental Concepts
        • ⭐Introduction to the Stellar network
        • ⛓️Introduction to blockchain technology
        • 💵Introduction to payments in Stellar
        • 🧑Accounts
      • Core Features & Mechanisms
        • 🔐Assets: Powering Digital Value Exchange
        • Assets Issuance: Manage digital assets effortlessly on Stellar
        • 💸Transactions: At Stellar Core
        • 👮‍♂️Signatures in Stellar: Who, how much and to what is authorized
      • Payments & Transactions
        • 💰Payments: Simplifying Transactions with Stellar
        • ⛓️Path Payments: Convert Assets at Minimal Cost
        • ⛽Fee-Bump: How to pay for other people's transactions
      • Developer & Integration Tools
        • 👩‍🔬Stellar Laboratory: Stellar at hand for everyone
        • 🚪Faucet: Easy Access to Free Blockchain Assets
        • 🧰Stellar Wallets Kit: A kit to handle all Stellar Wallets at once with a simple API
        • ✍️Simple Signer: A wallet aggregator and transaction signer
      • Advanced Development & Testing
        • 🧪How to Create Integration Tests Using GitHub Actions and Stellar's Docker Image
  • 🎨Design Sprint
    • 🌅Introduction
    • 1️⃣Day 1 - Validate your problem and define your MVP's Scope
    • 2️⃣Day 2 - Build a prototype to validate with real users
    • 3️⃣Day 3 - Define the technical architecture
    • 4️⃣Day 4: Develop your Go To Market Strategy & Pitch Deck
    • 5️⃣Day 5: Compile all the information
    • 👀Sample Completed Design Sprint
Powered by GitBook
On this page
  1. Fundamentals of Integrating with Stellar
  2. Resources
  3. Core Features & Mechanisms

Signatures in Stellar: Who, how much and to what is authorized

PreviousTransactions: At Stellar CoreNextPayments & Transactions

Last updated 3 months ago

If you’ve been following the previous chapter from this learning path, you’ll now know that signatures are the way Stellar validates a transaction (and all of the operations within it) are authorized. Now, signing a transaction with the correct signature is just the first step, today we’ll take deep dive into signatures, authorization and transactions validation in Stellar and will approach Each operation in Stellar falls under a specific threshold category: low, medium, or high. You can think of thresholds as the level of authorization required to perform an specific operation for each account, which should translate to how much weight a signature requires to perform an operation. In the provided by Stellar you can find the specific threshold for each operation, and later, in your account you can find it specified as a number between 0 and 255.

By default all operations thresholds are set to 0, but you can specify a weight for each threshold for your account using the set options operation. Keep in mind the recommendation is always to set the lower one for the Low Threshold and the highest for the High one.

Now that you understand thresholds the next thing you’ll want to approach is signatures weights. By default each account has a single signer, also named as master, whose original weight is 1. But in some cases you’ll want to add more than one signature, for usage purposes or for safety. In this cases you could wanna set a higher authorization level for an specific account, to enable it to perform more delicate operations and a lower one for others to perform daily operations

Note that if you set thresholds higher than the one set for your Master key and there’s no other signer set for the related account you’ll block any fund in that account, as no other account will be able to sign these transactions.

The set operations will also allow you to add several signers, for each one of them you’ll need to specify a type and set a weight. If you’d like to remove a signer you can simply set the weight to 0 and submit the transaction

Once you have added signers what Stellar is gonna do when authorizing your transaction is to add up the weight for all of the signers accounts to check if that sums up to the threshold required. Once a signature threshold is met, if there are leftover signatures, the transaction will fail. For example, if your transaction requires three signatures, providing more than three signatures, even if they are all valid, will result in a failed transaction error: TX_BAD_AUTH_EXTRA.

To enable some advanced smart contract features there are a couple of additional signature types. These signature types also have weights and can be added and removed similarly to normal signature types

  • Pre authorized transactions You can pre-approve a transaction by adding the hash of the following transaction as a signer. To do this, you need to prepare the transaction with the correct sequence number, get its hash, and add it as a signer. Once the transaction is applied (whether it succeeds or fails), the signer is automatically removed. If the transaction is never submitted, the signer stays on the account and must be manually removed using the Set Options operation.

  • Hash signatures This type of signature will allow anyone who knows x to sign the transaction. It is particularly useful in atomic cross-chain swaps which are needed for inter-blockchain protocols like lightning networks. To use it, start by creating a random 256-bit value, which we call x. The SHA256 hash of that value can be added as a signer of type hash(x). Then in order to authorize a transaction, x is added as one of the signatures of the transaction. Keep in mind that x will be known to the world as soon as a transaction is submitted to the network with x as a signature. This means anyone will be able to sign for that account with the hash(x) signer at that point. Often you want there to be additional signers so someone must have a particular secret key and know x in order to reach the weight threshold required to authorize transactions on the account.

There’s many cases in which a multisig account will be the best way to go. Think of a share account that should allow all users to perform basic operations such as payments or setting offers but should require the authorization of all users to perform a change in the account setting or to merge it. Or think of a company account, which should allow a mix of admins to perform payments to ensure procedures but also allow a higher member to perform the operation solo by assigning them a higher signature weight.

Conclusion

Signatures in Stellar play a crucial role in transaction validation and authorization. By understanding thresholds, signature weights, and advanced signature types like pre-authorized transactions and hash(x) signatures, you can manage account security and enable complex use cases like atomic cross-chain swaps. Carefully configuring thresholds and signers ensures both flexibility and safety, preventing issues such as locked accounts or failed transactions due to mismatched authorization levels.

📚
👷
👮‍♂️
List of Operations