# Signing a Transaction

Transactions in zkBob are signed by the spending key $$\sigma$$. To verify a transaction signature the prover should use an intermediate key A.

### Transaction hashing

A client application should sign a 'composite' transaction hash instead of full transaction data. The transaction hash is calculated from the input and output hashes:

$$H = Hash\_{sponge}(Hash\_{account}(Acc^\text{in}), Hash\_{note}(Note\_0^\text{in}), Hash\_{note}(Note\_1^\text{in}), Hash\_{note}(Note\_2^\text{in}), TxCommit)$$&#x20;

where

* $$Hash$$ is a [Poseidon multi-hash (sponged) routine](https://docs.zkbob.com/implementation/untitled/the-poseidon-hash) in the different modes
* $$Acc^\text{in}$$is an input account
* $$Note\_i^\text{in}$$is an input notes,
* $$TxCommit$$ - is a transaction commitment hash (Merkle subtree root). It depends on transaction output account and notes.

### Signing

Next, a client uses the account spending key to sign a transaction hash $$H$$:

$$r = Blake2s(\sigma, H)$$, where[$$Blake2s$$ is the 256-bit hash function ](https://www.blake2.net/blake2x.pdf)

$$R = rG$$, $$A=\sigma G$$ (moving $$r$$ and $$\sigma$$ to the JubJub Elliptic curve field)

$$S = r + Hash\_{eddsa}(R.x, A.x, H)\sigma$$

The output signature $$(S, R)$$ will be sent with a intermediate key $$A = \sigma G$$

### Verifying

To verify a transaction signature a validator should perform the following computations:

$$SG == R + Hash\_{eddsa}(R.x, A.x, H)A$$


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zkbob.com/implementation/transaction-overview/signing-a-transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
