---
bip: 458
title: "Half-Aggregation of BIP 340 Signatures"
status: Draft
type: Specification
layer: "Applications"
authors: ["Tim Ruffing","Jonas Nick","Fabian Jahr"]
assigned: 2026-07-02
last_modified: 2026-06-28
requires: [340]
topics: ["signatures"]
license: "CC0-1.0 OR MIT"
url: https://bipexplorer.com/bip/458
source: https://github.com/bitcoin/bips/blob/master/bip-0458.mediawiki
---

# BIP 458: Half-Aggregation of BIP 340 Signatures

## Introduction

### Abstract

This document describes _half-aggregation_ of BIP 340 signatures. Half-aggregation is a non-interactive process for aggregating a collection of signatures into a single aggregate signature. The size of the resulting aggregate signature is approximately half of the combined size of the original signatures.

### Copyright

This document, along with the [reference implementation](https://github.com/bitcoin/bips/blob/master/bip-0458/halfagg.py) and [test vectors](https://github.com/bitcoin/bips/blob/master/bip-0458/vectors/), is licensed under CC0-1.0 or the MIT License, at your option. The vendored copy of the secp256k1lab library in [bip-0458/secp256k1lab](https://github.com/bitcoin/bips/blob/master/bip-0458/secp256k1lab/) is licensed under the MIT License only, as stated in its [COPYING](https://github.com/bitcoin/bips/blob/master/bip-0458/secp256k1lab/COPYING) file.

### Motivation

Half-aggregation is applicable if there is a verifier that needs to verify multiple signatures. Instead of sending individual signatures to the verifier, the signatures can be compressed into a single aggregate signature and sent to the verifier. If the verifier can successfully verify the aggregate signature, the verifier can be sure that the individual signatures would have passed verification.

The purpose of half-aggregation is to reduce the size of the data that is sent to the verifier. While _n_ BIP 340 signatures are _64\*n_ bytes, a half-aggregate of the same signatures is _32\*n + 32_ bytes. The process of half-aggregation is straightforward: it is a pure function of the input signatures, public keys, and messages. It is non-interactive and does _not_ require cooperation from other parties, including signers or verifiers. This is unlike interactive multisignature schemes such as MuSig2 ([BIP 327](https://bipexplorer.com/bip/327)), in which signers cooperate to produce a single signature under a single aggregate public key. In half-aggregation, there is no aggregate key, and the aggregate signature is verified against the individual public keys and messages.

There are a variety of scenarios where half-aggregation of BIP 340 signatures is useful. To keep this section brief and avoid getting outdated quickly, we focus on listing example applications and defer the detailed discussion of the application-specific trade-offs to other places.

One example is the Lightning Network routing gossip protocol, which [as of this writing](https://github.com/lightning/bolts/blob/2e8f2095a36afb9de38da0f3f0051c7dc16dfc36/07-routing-gossip.md) involves messages that contain ECDSA signatures. If the signature scheme was changed to BIP 340, half-aggregation could reduce the total amount of gossiped data. Instead of sending individual gossip messages, nodes could assemble a batch of messages and half-aggregate the signatures of the individual messages into a single signature for the batch.

Another application of half-aggregation is within the Bitcoin consensus protocol. In particular, it has been discussed in the context of the [Graftroot proposal](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-February/015700.html). Half-aggregation would allow Graftroot spending to be as efficient as best-case Taproot spends by aggregating the signature of the _surrogate script_ and signatures that satisfy this script. Moreover, half-aggregation improves the efficiency of proposed Bitcoin script opcodes that verify multiple signatures, such as [OP\_EVICT](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-February/019926.html). We can also imagine adding a Bitcoin script opcode that verifies a half-aggregate signature, allowing for more efficient non-interactive multi and threshold signatures.

Half-aggregation can also be applied to the signatures in the inputs of Bitcoin transactions, a process known as cross-input signature aggregation (CISA). This [reduces the size of an average transaction](https://github.com/ElementsProject/cross-input-aggregation/blob/master/savings.org) by 20.6% and the weight by 7.6%. A known downside of using half-aggregation is that some uses of adaptor signature protocols [may be incompatible](https://github.com/ElementsProject/cross-input-aggregation#half-aggregation-and-adaptor-signatures). Usually, CISA is proposed with interactive _full_ signature aggregation instead of non-interactive half-aggregation because creating a valid transaction already requires cooperation, and full signature aggregation is more efficient. However, the difference in complexity between half-aggregation and full aggregation is so significant that basing a CISA on half-aggregation is a legitimate approach.

The most invasive application to Bitcoin's consensus would be block-wide signature aggregation. It refers to a process where block producers aggregate as many transaction signatures as possible. In the best case, a full block would only have a single half-aggregate signature. While this is attractive from the efficiency perspective, block-wide aggregation requires more research (and, in particular, special attention to handling [reorgs](https://github.com/ElementsProject/cross-input-aggregation#half-aggregation-and-reorgs)).

### Rationale

The idea for half-aggregation of Schnorr signatures was brought up in the context of block-wide signature aggregation [by Tadge Dryja on the Bitcoin mailing list](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014272.html) in 2017. The scheme had a security flaw that was [noticed](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014306.html) and [fixed](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014308.html) shortly after by Russell O'Connor and Andrew Poelstra. In 2021 [Chalkias, Garillot, Kondi and Nikolaenko](https://eprint.iacr.org/2021/350) published a security proof in the random oracle model (ROM) that reduces the security of half-aggregation to the security of Schnorr signatures. [Chen and Zhao](https://eprint.iacr.org/2022/222.pdf) were able to produce a tight proof in the ROM and algebraic group model in the following year. Moreover, they came up with an elegant approach to incremental aggregation that is used in this document.

-   Incremental aggregation allows non-interactively aggregating additional BIP 340 signatures into an existing half-aggregate signature.

-   A half-aggregate signature of _u_ BIP 340 input signatures is serialized as the _(u+1)⋅32_\-byte array _r0 || ... || ru-1 || bytes(s)_ where _ri_ is a 32-byte array from input signature _i_ and _s_ is a scalar aggregate (see below for details).

-   This document does _not_ specify the aggregation of multiple aggregate signatures (yet). It is possible, but requires changing the encoding of an aggregate signature. Since it is not possible to undo the aggregation of the s-values, when verifying of such an aggregate signature the randomizers need to be the same as when verifying the individual aggregate signature. Therefore, the aggregate signature needs to encode a tree that reveals how the individual signatures were aggregated and how the resulting aggregate signatures were reaggregated.

-   The first randomizer _z0_ is fixed to the constant _1_, which speeds up verification because _z0⋅R0 = R0_. This optimization has been suggested and proven secure by [Chen and Zhao](https://eprint.iacr.org/2022/222.pdf).

-   This BIP does not impose a maximum number of signatures that can be aggregated in a single half-aggregate signature. Implementations may enforce limits, e.g., to facilitate testing, to prevent resource exhaustion and integer overflows. Additionally, applications should enforce a (possibly lower) limit that suits their needs, taking into account that processing large aggregates may take a considerable amount of time. We note that there must be agreement over the limits in consensus-critical applications.

-   Messages must be exactly 32 bytes, the size of a transaction sighash. This keeps the input of each randomizer hash unambiguous, since it concatenates r-values, public keys and messages without length prefixes.

-   The input of each randomizer hash is a prefix of the input of the next one. Implementations should stream the concatenation through a single hash state once and finalize a copy of that state for each randomizer, which keeps the hashing linear in the number of signatures instead of quadratic.

## Description

### Specification

The specification is written in Python and can be found in [halfagg.py](https://github.com/bitcoin/bips/blob/master/bip-0458/halfagg.py). Note that the specification depends on a vendored copy of the [secp256k1lab library](https://github.com/secp256k1lab/secp256k1lab).

### Test Vectors

Test vectors are provided in [vectors](https://github.com/bitcoin/bips/blob/master/bip-0458/vectors/) and are generated with a [generator script](https://github.com/bitcoin/bips/blob/master/bip-0458/gen_test_vectors.py). The specification can be executed with the test vectors by running [the run\_test\_vectors script](https://github.com/bitcoin/bips/blob/master/bip-0458/run_test_vectors.py).

### Pseudocode

The following pseudocode is _not_ a specification but is only intended to augment the actual Python [specification](#specification).

#### Notation

The following conventions are used, with constants as defined for [secp256k1](https://www.secg.org/sec2-v2.pdf). We note that adapting this specification to other elliptic curves is not straightforward and can result in an insecure scheme[1].

-   Lowercase variables represent integers or byte arrays.
    
    -   The constant _p_ refers to the field size, _0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F_.
    
    -   The constant _n_ refers to the curve order, _0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141_.
-   Uppercase variables refer to points on the curve with equation _y2 = x3 + 7_ over the integers modulo _p_.
    
    -   _is\_infinite(P)_ returns whether or not _P_ is the point at infinity.
    
    -   _x(P)_ and _y(P)_ are integers in the range _0..p-1_ and refer to the X and Y coordinates of a point _P_ (assuming it is not infinity).
    
    -   The constant _G_ refers to the base point, for which _x(G) = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798_ and _y(G) = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8_.
    
    -   Addition of points refers to the usual [elliptic curve group operation](https://en.wikipedia.org/wiki/Elliptic_curve#The_group_law).
    
    -   [Multiplication (⋅) of an integer and a point](https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication) refers to the repeated application of the group operation.
-   Functions and operations:
    
    -   _||_ refers to byte array concatenation.
    
    -   The function _x\[i:j\]_, where _x_ is a byte array and _i, j ≥ 0_, returns a _(j - i)_\-byte array with a copy of the _i_\-th byte (inclusive) to the _j_\-th byte (exclusive) of _x_.
    
    -   The function _bytes(x)_, where _x_ is an integer, returns the 32-byte encoding of _x_, most significant byte first.
    
    -   The function _len(x)_ where _x_ is a byte array returns the length of the array.
    
    -   The function _int(x)_, where _x_ is a 32-byte array, returns the 256-bit unsigned integer whose most significant byte first encoding is _x_.
    
    -   The function _has\_even\_y(P)_, where _P_ is a point for which _not is\_infinite(P)_, returns _y(P) mod 2 = 0_.
    
    -   The function _lift\_x(x)_, where _x_ is a 256-bit unsigned integer, returns the point _P_ for which _x(P) = x_

Given a candidate X coordinate _x_ in the range _0..p-1_, there exist either exactly two or exactly zero valid Y coordinates. If no valid Y coordinate exists, then _x_ is not a valid X coordinate either, i.e., no point _P_ exists for which _x(P) = x_. The valid Y coordinates for a given candidate _x_ are the square roots of _c = x3 + 7 mod p_ and they can be computed as _y = ±c(p+1)/4 mod p_ (see [Quadratic residue](https://en.wikipedia.org/wiki/Quadratic_residue#Prime_or_prime_power_modulus)) if they exist, which can be checked by squaring and comparing with _c_. and _has\_even\_y(P)_, or fails if _x_ is greater than _p-1_ or no such point exists. The function _lift\_x(x)_ is equivalent to the following pseudocode:

-   -   -   Fail if _x ≥ p_.
        
        -   Let _c = x3 + 7 mod p_.
        
        -   Let _y = c(p+1)/4 mod p_.
        
        -   Fail if _c ≠ y2 mod p_.
        
        -   Return the unique point _P_ such that _x(P) = x_ and _y(P) = y_ if _y mod 2 = 0_ or _y(P) = p-y_ otherwise.
    -   The function _hashtag(x)_ where _tag_ is a UTF-8 encoded tag name and _x_ is a byte array returns the 32-byte hash _SHA256(SHA256(tag) || SHA256(tag) || x)_.
-   Other:
    -   Tuples are written by listing the elements within parentheses and separated by commas. For example, _(2, 3, 1)_ is a tuple.

In the [reference implementation](#specification), these operations map to the following [secp256k1lab](https://github.com/secp256k1lab/secp256k1lab) library methods, where _GE_ and _Scalar_ represent points and scalars:

| Notation | secp256k1lab |
| --- | --- |
| _lift\_x(int(x))_ | _GE.from\_bytes\_xonly(x)_ |
| _int(x)_, failing if _≥ n_ | _Scalar.from\_bytes\_checked(x)_ |
| _int(x) mod n_ | _Scalar.from\_bytes\_wrapping(x)_ |
| _bytes(s)_ | _s.to\_bytes()_ |
| _hashtag(x)_ | _tagged\_hash(tag, x)_ |

#### Aggregate

_Aggregate_ takes an array of public key, message and signature triples and returns an aggregate signature. If every triple _(p, m, s)_ is valid (i.e., _Verify(p, m, s)_ as defined in BIP 340 returns true), then the returned aggregate signature and the array of _(p, m)_ tuples passes _VerifyAggregate_. (However, the inverse does not hold: given suitable valid triples, it is possible to construct an input array to _Aggregate_ which contains invalid triples, but for which _VerifyAggregate_ will accept the aggregate signature returned by _Aggregate_. If this is undesired, input triples should be verified individually before passing them to _Aggregate_.)

Input:

-   _pms0..u-1_: an array of _u_ triples, where the first element of each triple is a 32-byte public key, the second element is a 32-byte message and the third element is a 64-byte BIP 340 signature

**_Aggregate(pms0..u-1)_**:

-   Let _aggsig = bytes(0)_

-   Let _pm\_aggd_ be an empty array

-   Return _IncAggregate(aggsig, pm\_aggd, pms0..u-1)_; fail if that fails.

#### IncAggregate

_IncAggregate_ takes an aggregate signature, an array of public key and message tuples corresponding to the aggregate signature, and an additional array of public key, message and signature triples. It aggregates the additional array of triples into the existing aggregate signature and returns the resulting new aggregate signature. In other words, if _VerifyAggregate(aggsig, pm\_aggd)_ passes and every triple _(p, m, s)_ in _pms\_to\_agg_ is valid (i.e., _Verify(p, m, s)_ as defined in BIP 340 returns true), then the returned aggregate signature along with the array of _(p, m)_ tuples of _pm\_aggd_ and _pms\_to\_agg_ passes _VerifyAggregate_. (However, the inverse does not hold: given a suitable valid aggregate signature and suitable valid triples, it is possible to construct inputs to _IncAggregate_ which contain an invalid aggregate signature or invalid triples, but for which _VerifyAggregate_ will accept the aggregate signature returned by _IncAggregate_. If this is undesired, the input triples and the input aggregate signature should be verified individually before passing them to _IncAggregate_.)

Input:

-   _aggsig_ : a byte array

-   _pm\_aggd0..v-1_: an array of _v_ tuples, where the first element of each tuple is a 32-byte public key and the second element is a 32-byte message

-   _pms\_to\_agg0..u-1_: an array of _u_ triples, where the first element of each tuple is a 32-byte public key, the second element is a 32-byte message and the third element is a 64-byte BIP 340 signature

**_IncAggregate(aggsig, pm\_aggd0..v-1, pms\_to\_agg0..u-1)_**:

-   Fail if _len(aggsig) ≠ 32 \* (v + 1)_

-   For _i = 0 .. v-1_:
    
    -   Let _(pki, mi) = pm\_aggdi_
    
    -   Let _ri = aggsig\[i⋅32:(i+1)⋅32\]_
-   For _i = v .. v+u-1_:
    
    -   Let _(pki, mi, sigi) = pms\_to\_aggi-v_
    
    -   Let _ri = sigi\[0:32\]_
    
    -   Let _si = int(sigi\[32:64\])_; fail if _si ≥ n_
    
    -   If _i = 0_:
        -   Let _zi = 1_
    -   Else:
        -   Let _zi = int(hashBIP0458/randomizer(r0 || pk0 || m0 || ... || ri || pki || mi)) mod n_
-   Let _sagg = int(aggsig\[v⋅32:(v+1)⋅32\])_; fail if _sagg ≥ n_

-   Let _s = sagg + zv⋅sv + ... + zv+u-1⋅sv+u-1 mod n_

-   Return _r0 || ... || rv+u-1 || bytes(s)_

#### VerifyAggregate

_VerifyAggregate_ verifies a given aggregate signature against an array of public key and message tuples.

Input:

-   _aggsig_ : a byte array

-   _pm\_aggd0..u-1_: an array of _u_ tuples, where the first element of each tuple is a 32-byte public key and the second element is a 32-byte message

**_VerifyAggregate(aggsig, pm\_aggd0..u-1)_**: The algorithm _VerifyAggregate(aggsig, pm\_aggd0..u-1)_ is defined as:

-   Fail if _len(aggsig) ≠ 32 \* (u + 1)_

-   For _i = 0 .. u-1_:
    
    -   Let _(pki, mi) = pm\_aggdi_
    
    -   Let _Pi = lift\_x(int(pki))_; fail if that fails
    
    -   Let _ri = aggsig\[i⋅32:(i+1)⋅32\]_
    
    -   Let _Ri = lift\_x(int(ri))_; fail if that fails
    
    -   Let _ei = int(hashBIP0340/challenge(ri || pki || mi)) mod n_
    
    -   If _i = 0_:
        -   Let _zi = 1_
    -   Else:
        -   Let _zi = int(hashBIP0458/randomizer(r0 || pk0 || m0 || ... || ri || pki || mi)) mod n_
-   Let _s = int(aggsig\[u⋅32:(u+1)⋅32\])_; fail if _s ≥ n_

-   Fail if _s⋅G ≠ z0⋅(R0 + e0⋅P0) + ... + zu-1⋅(Ru-1 + eu-1⋅Pu-1)_

-   Return success iff no failure occurred before reaching this point.

The verification algorithm is similar to [BIP340 Batch Verification](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#batch-verification). As in BIP340, using an [efficient algorithm for computing the sum of multiple EC multiplications](https://bitcoin.stackexchange.com/a/80702/109853) can significantly speed up verification.

## Backward Compatibility

Half-aggregation specifies a new, optional construction for aggregating existing BIP 340 signatures. It does not change the validation of individual BIP 340 signatures and does not affect any existing Bitcoin consensus rules or protocol behavior. Therefore, this BIP introduces no backward compatibility concerns.

1.  Among other pitfalls, using the specification with a curve whose order is not close to the size of the range of the nonce derivation function is insecure.
