Repository navigation
BIP458: Half-Aggregation of BIP 340 Signatures - #2205
Conversation
jonatack
left a comment
There was a problem hiding this comment.
Looks quite complete. Might be good to add a backward compatibility section (if not needed, that could be explicitly stated).
Code is based on the secp256k1-zkp implementation. Test vectors based on the draft BIP: bitcoin/bips#2205 Co-authored-by: Benedikt <crypto@benedikt-wagner.dev>
Code is based on the secp256k1-zkp implementation. Test vectors based on the draft BIP: bitcoin/bips#2205 Co-authored-by: Benedikt <crypto@benedikt-wagner.dev>
Code is based on the secp256k1-zkp implementation. Test vectors based on the draft BIP: bitcoin/bips#2205 Co-authored-by: Benedikt <crypto@benedikt-wagner.dev>
|
Addressed your comments @jonatack , thanks!
I added a "section not needed" section ;) |
theStack
left a comment
There was a problem hiding this comment.
Nice! Left some notation and style nits below (mostly related to secp256k1lab usage).
|
|
||
| ==== Notation ==== | ||
|
|
||
| The following conventions are used, with constants as defined for [https://www.secg.org/sec2-v2.pdf secp256k1]. We note that adapting this specification to other elliptic curves is not straightforward and can result in an insecure scheme<ref>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.</ref>. |
There was a problem hiding this comment.
Fwiw, in BIP-445 a different notation is used (for the first time, as far as I'm aware) that leans more to secp256k1lab, with a table showing how the notation maps to the lab functions: https://github.com/siv2r/bips/blob/bip-frost-signing/bip-0445.md?plain=1#L255
(I found that quite a nice idea for improved readability and hopefully easier navigation through the reference implementation; but that's of course more a nit than a requirement; ultimately it's up to the BIP authors).
There was a problem hiding this comment.
Thanks, I didn't quite pick up on this despite looking at the BIP445 draft for some inspiration. But I am not sure it's the best idea to adapt this notation fully here. I think there is also some value in having the notation closer to BIP340 which is a prerequisite to this BIP here while BIP445 is not directly related. I did steal the idea of the mapping table though, please let me know if you agree with this decision and think the mapping table on it's own is helpful.
There was a problem hiding this comment.
Yeah good point, keeping the notation intentionally close to BIP340 seems reasonable. I think the small mapping table you added is definitely helpful for (reference implementation) readers.
|
Addressed feedback from @theStack , thanks a lot! |
murchandamus
left a comment
There was a problem hiding this comment.
Thanks, that was a splendid read. I especially enjoyed the ventilated prose. Looks like you have all the sections covered, already have a reference implementation, and the text is very polished already. I don’t have any improvement suggestions at this time, so let’s just go right ahead: assigned BIP454. Please move the document and auxiliary files to the corresponding file paths, update the BIP and Assigned headers, and add a table entry to the README.mediawiki.
Nice, 99% of that praise goes to @jonasnick and @real-or-random !
Thanks! I applied the necessary changes. |
murchandamus
left a comment
There was a problem hiding this comment.
Changes LGTM. Since this just got opened, I suggest we let it simmer for at least a couple weeks to see if there is any more useful review, but otherwise, this seems pretty much ready for publication to me. What do you think?
Yeah, that sounds good for me. I will publish the draft for fullagg shortly and maybe there will be some additional feedback here from having the two side by side. |
|
Assigned new number per request of @fjahr. Let’s refer to this as 458 instead of 454. Please update the table and preamble accordingly. |
Done! Thanks and sorry for the inconvenience. |
|
Since the Full-Aggregation BIP has just been out for a few days, I’ll hold off on merging this. Are you also expecting to submit the CISA BIP soon or will that be much later? |
I hope to do it very soon, a couple of days |
|
Great, let’s aim to publish them together, when they all have been open for a bit. |
| Status: Draft | ||
| Type: Specification | ||
| Assigned: 2026-07-02 | ||
| License: BSD-3-Clause |
There was a problem hiding this comment.
| License: BSD-3-Clause | |
| License: CC0-1.0 or MIT |
It may not matter at all in the future, but let's change this if we all agree here (cc @jonasnick).
I helped with the Licensing section in BIP3, and there's a reason why this has License: CC0-1.0 or MIT as an example:
- When it comes to the text, CC0 is made with documents in mind and not just code, and works internationally. Plus, it's great to have the test vectors in CC0, so people can copy them to their repos without any legal obligation.
- When it comes to code, MIT is just the more natural choice given that Bitcoin Core and most of the ecosystem is MIT-licensed. (For some reason, people started licensing BIPs under BSD3 licenses... There's nothing wrong with mixing MIT and BSD, but the ability to distribute all your code under a single license makes things a tiny bit easier.)
And with the OR we just give readers/users the best of both worlds.
(The same comment applies to the full-agg BIP modulo that you can decide on your own there.)
There was a problem hiding this comment.
Sounds good to me! I will push the change but I can revert if @jonasnick has any objections! I will make the same change in BIP459.
There was a problem hiding this comment.
No objection, sounds good.
Following bitcoin/bips#2205
|
Added a small note on how to avoid quadratic hashing in implementation code |
|
Addressed feedback from @theStack , thanks a lot! |
This comment was marked as spam.
This comment was marked as spam.
|
Applied the latest comments from #2210 here as well: the randomizer tag is now Note that the tag change means the spec now diverges from the |
PeterXMR
left a comment
There was a problem hiding this comment.
Nice work. One gap: the 32/32/64-byte input sizes are stated in the Input sections but never enforced, in either the spec or halfagg.py. On the current head, Aggregate + VerifyAggregate accept 0-, 31-, 33- and 100-byte messages and a 65-byte sig. A 31-byte pk hits an AssertionError instead of failing. Suggestions inline. Happy to add a FALSE verify vector for a 33-byte message (aggsig valid over that message) if useful.
Add a vendored copy of the secp256k1lab library (master branch, commit a265da139aea27386085a2a8760f8698e1bda64e) that the half-aggregation reference implementation and test vector scripts depend on.
fametrano
left a comment
There was a problem hiding this comment.
Comment: the size checks are in halfagg.py but not yet in the pseudocode, and the vectors miss two of the sizes. I wrote an independent implementation from the pseudocode on btclib-ecc to check the size limits PeterXMR raised. All 47 vectors pass at the current head, and halfagg.py now refuses each wrong size I tried.
The pseudocode only says "32-byte" in the Input lists. It has no fail step for the key, message or signature sizes, though it has one for aggsig. Copying the line PeterXMR suggested into IncAggregate and VerifyAggregate would close that. The vectors only test messages that are too long and keys that are too short. A check of len(m) > 32 alone, or len(pk) < 32 alone, passes all 47. Two FALSE verify vectors catch both, each a valid signature over the wrong-size input. The first is vector 23 built with create_signature(0, 31), a 31-byte message. The second is vector 1 with its key prefixed by 02, a 33-byte key that a library accepting SEC keys verifies as true. I ran the vectors through my implementation and halfagg.py, and the weakened check through mine. I can share the code.
* Add BIP458 half-aggregation of BIP340 signatures (issue #365) ecc.ecc.ssa_halfagg aggregates BIP340 signatures into one signature of 32*(u+1) bytes, adds signatures to an existing aggregate, and verifies an aggregate against its (public key, message) pairs: aggregate, inc_aggregate, verify and assert_as_valid. It is written from the pseudocode of bitcoin/bips#2205 at 2f436b02f60b, without reading the reference code. The draft's three vector files are vendored under tests/schemes/_data/ and run, and every vector agrees but the empty aggregate described below. verify follows the tree's bool contract: a key, a message or an aggregate of the wrong size raises, and an empty list of pairs raises where BIP458 accepts an empty aggregate with s = 0, as ssa.batch_verify refuses an empty batch, and CONTRIBUTING.md's paragraph on that exception names both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Answer review of the BIP458 half-aggregation (issue #365) - curve.py: name the callers of _multi_mult_x_only_var without counting them. - curve.py: multi_mult_var's docstring names the verifications, not "those last two". - tests/_data/README.md: link ISS 365. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Raise EccValueError for a tuple of the wrong arity in ssa_halfagg (issue #365) A pair where a triple belongs, and the converse, is a wrong value, as for a Point in tests/input_validation_test.py, not a wrong type. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Answer review of the wrong-arity decision (issue #365) - CONTRIBUTING.md: a tuple of the wrong arity is a wrong value. - tests/input_validation_test.py: _WRONG_VALUE's header names that exception. - ssa_halfagg.py: inc_aggregate and verify name the wrong arity among what raises. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Rewrap the verify docstring to 80 columns (issue #365) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Cut the _WRONG_VALUE header to the arity exception (issue #365) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Narrow the wrong-arity paragraph to what the tree keeps (issue #365) negate and negate_jac raise EccTypeError for a tuple of the wrong length, and tests/curves/curve_test.py pins it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Name negate and negate_jac as the wrong-arity exception (issue #365) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> * Call the negate EccTypeError a leftover (issue #365) negate and negate_jac raise EccTypeError for a tuple of the wrong length. That is a leftover, not a choice: #377 moves them to EccValueError. CONTRIBUTING.md says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> --------- Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This is intentional. The pseudocode follows the examples of BIP 340 and BIP 327, which have fixed sizes on the input and use fail steps only for value checks.
I added a 31-byte message and your |
|
You are right, and I am sorry for the extra round. BIP 340 and BIP 327 give the sizes only in their input lists, so the fail steps I asked for in the pseudocode would break that pattern. I withdraw that part of my earlier review. Thank you for the new vectors. I ran all 53 at fe78361 against btclib-ecc, an independent implementation I maintain: 52 pass. The other is verify vector 0, the empty aggregate, which btclib-ecc refuses on purpose. Verify vector 24 verifies as TRUE if its |
This is the BIP draft for half-aggregation of BIP340 Schnorr signatures, which has marinated at https://github.com/BlockstreamResearch/cross-input-aggregation/blob/master/half-aggregation.mediawiki long enough.
Mailing list discussion: https://gnusha.org/pi/bitcoindev/33f275c2-06b1-4b4a-2a75-cafe36836503@gmail.com/
Compared to the master version of the BIP linked above and the state of things at the time of sharing this on the mailing list, this version has a few minor typo fixes as well as three significant changes:
Given the Python reference implementation, I am vendoring the latest master of secp256k1lab with the BIP, as seems to be the standard with other BIPs (seen merged at 374 and in the pull for 445).