Skip to content

Commit a56b95b

Browse files
committed
Address halfagg nits from zkp
- we may want to add a header to the include file that links to the BIP - there's still a mention of aggsig_size - we may want to move aggregate before inc_aggregate - we should mention expected size of input aggsig array in_aggregate - 'Should be aggsig_len = 32*(n+1)' -> 'Must be'
1 parent 747a01a commit a56b95b

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

include/secp256k1_schnorrsig_halfagg.h

+35-29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@
88
extern "C" {
99
#endif
1010

11+
/** This module implements incremental (Half-)Aggregation of Schnorr
12+
* signatures as specificed by the Bitcoin Improvement Proposal draft
13+
* "Half-Aggregation of BIP 340 signatures"
14+
* (https://github.com/BlockstreamResearch/cross-input-aggregation/blob/master/half-aggregation.mediawiki).
15+
*/
16+
17+
/** (Half-)Aggregate a sequence of Schnorr signatures.
18+
*
19+
* Returns 1 on success, 0 on failure.
20+
* Args: ctx: a secp256k1 context object.
21+
* Out: aggsig: pointer to an array of aggsig_len many bytes to
22+
* store the serialized aggregate signature. The size
23+
* is expected to be 32*(n+1) bytes.
24+
* In/Out: aggsig_len: size of the aggsig array that is passed in bytes;
25+
* will be overwritten to be the exact size of aggsig.
26+
* In: pubkeys: Array of n many x-only public keys.
27+
* Can only be NULL if n is 0.
28+
* msgs32: Array of n many 32-byte messages.
29+
* Can only be NULL if n is 0.
30+
* sigs64: Array of n many 64-byte signatures.
31+
* Can only be NULL if n is 0.
32+
* n: number of signatures to be aggregated.
33+
*/
34+
SECP256K1_API int secp256k1_schnorrsig_aggregate(
35+
const secp256k1_context *ctx,
36+
unsigned char *aggsig,
37+
size_t *aggsig_len,
38+
const secp256k1_xonly_pubkey *pubkeys,
39+
const unsigned char *msgs32,
40+
const unsigned char *sigs64,
41+
size_t n
42+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
1143

1244
/** Incrementally (Half-)Aggregate a sequence of Schnorr
1345
* signatures to an existing half-aggregate signature.
@@ -22,7 +54,7 @@ extern "C" {
2254
* aggsig_len: size of aggsig array in bytes.
2355
* Should be large enough to hold the new
2456
* serialized aggregate signature, i.e.,
25-
* should satisfy aggsig_size >= 32*(n_before+n_new+1).
57+
* should satisfy aggsig_len >= 32*(n_before+n_new+1).
2658
* It will be overwritten to be the exact size of the
2759
* resulting aggsig.
2860
* In: all_pubkeys: Array of (n_before + n_new) many x-only public keys,
@@ -51,32 +83,6 @@ SECP256K1_API int secp256k1_schnorrsig_inc_aggregate(
5183
size_t n_new
5284
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
5385

54-
/** (Half-)Aggregate a sequence of Schnorr signatures.
55-
*
56-
* Returns 1 on success, 0 on failure.
57-
* Args: ctx: a secp256k1 context object.
58-
* Out: aggsig: pointer to an array of aggsig_len many bytes to
59-
* store the serialized aggregate signature.
60-
* In/Out: aggsig_len: size of the aggsig array that is passed in bytes;
61-
* will be overwritten to be the exact size of aggsig.
62-
* In: pubkeys: Array of n many x-only public keys.
63-
* Can only be NULL if n is 0.
64-
* msgs32: Array of n many 32-byte messages.
65-
* Can only be NULL if n is 0.
66-
* sigs64: Array of n many 64-byte signatures.
67-
* Can only be NULL if n is 0.
68-
* n: number of signatures to be aggregated.
69-
*/
70-
SECP256K1_API int secp256k1_schnorrsig_aggregate(
71-
const secp256k1_context *ctx,
72-
unsigned char *aggsig,
73-
size_t *aggsig_len,
74-
const secp256k1_xonly_pubkey *pubkeys,
75-
const unsigned char *msgs32,
76-
const unsigned char *sigs64,
77-
size_t n
78-
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
79-
8086
/** Verify a (Half-)aggregate Schnorr signature.
8187
*
8288
* Returns: 1: correct signature.
@@ -85,11 +91,11 @@ SECP256K1_API int secp256k1_schnorrsig_aggregate(
8591
* In: pubkeys: Array of n many x-only public keys. Can only be NULL if n is 0.
8692
* msgs32: Array of n many 32-byte messages. Can only be NULL if n is 0.
8793
* n: number of signatures to that have been aggregated.
88-
* aggsig: Pointer to an array of aggsig_size many bytes
94+
* aggsig: Pointer to an array of aggsig_len many bytes
8995
* containing the serialized aggregate
9096
* signature to be verified.
9197
* aggsig_len: Size of the aggregate signature in bytes.
92-
* Should be aggsig_len = 32*(n+1)
98+
* Must be aggsig_len = 32*(n+1)
9399
*/
94100
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_aggverify(
95101
const secp256k1_context *ctx,

0 commit comments

Comments
 (0)