Skip to content

Commit 58b129f

Browse files
committed
set z0 = 1 as in spec
1 parent da0df85 commit 58b129f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/modules/schnorrsig_halfagg/main_impl.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ int secp256k1_schnorrsig_inc_aggregate(const secp256k1_context *ctx, unsigned ch
9595
secp256k1_scalar_set_b32(&zi, hashoutput, NULL);
9696

9797
/* Step 2: s := s + zi*si */
98+
/* except if i == 0, then zi = 1 implicitly */
9899
secp256k1_scalar_set_b32(&si, &new_sigs64[(i-n_before)*64+32], &overflow);
99100
if (overflow) {
100101
return 0;
101102
}
102-
secp256k1_scalar_mul(&si, &si, &zi);
103+
if (i != 0) secp256k1_scalar_mul(&si, &si, &zi);
103104
secp256k1_scalar_add(&s, &s, &si);
104105
}
105106

@@ -189,7 +190,8 @@ int secp256k1_schnorrsig_aggverify(const secp256k1_context *ctx, const secp256k1
189190
secp256k1_gej_add_ge_var(&ti, &ti, &rp, NULL);
190191

191192
/* Step 3: rhs = rhs + zi*T_i */
192-
secp256k1_ecmult(&ti, &ti, &zi, NULL);
193+
/* Note that if i == 0, then zi = 1 implicitly */
194+
if (i != 0) secp256k1_ecmult(&ti, &ti, &zi, NULL);
193195
secp256k1_gej_add_var(&rhs, &rhs, &ti, NULL);
194196
}
195197

src/modules/schnorrsig_halfagg/tests_impl.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ void test_schnorrsig_aggverify_spec_vectors(void) {
115115
0x6f, 0x1b, 0xbf, 0xc2, 0xeb, 0x66, 0xd2, 0x9d,
116116
0x24, 0xb0, 0xca, 0xb7, 0x4d, 0x6b, 0x74, 0x5c,
117117
0x3c, 0xfb, 0x00, 0x9c, 0xc8, 0xfe, 0x4a, 0xa8,
118-
0x10, 0x8f, 0x33, 0x90, 0x76, 0x12, 0xfb, 0x74,
119-
0x84, 0x19, 0xeb, 0xc4, 0x00, 0x4b, 0x31, 0x69,
120-
0xe1, 0x6e, 0x35, 0xd5, 0xf1, 0x2b, 0x69, 0x3b,
121-
0x6b, 0xbc, 0x3d, 0x4a, 0x69, 0x82, 0xf2, 0xf6,
118+
0x0e, 0x06, 0x6c, 0x34, 0x81, 0x99, 0x36, 0x54,
119+
0x9f, 0xf4, 0x9b, 0x6f, 0xd4, 0xd4, 0x1e, 0xdf,
120+
0xc4, 0x01, 0xa3, 0x67, 0xb8, 0x7d, 0xdd, 0x59,
121+
0xfe, 0xe3, 0x81, 0x77, 0x96, 0x1c, 0x22, 0x5f,
122122
};
123123
size_t aggsig_len = sizeof(aggsig);
124124
size_t i;
@@ -162,10 +162,10 @@ void test_schnorrsig_aggverify_spec_vectors(void) {
162162
0x7c, 0x8c, 0x00, 0xf1, 0xb6, 0xd7, 0xe7, 0xd3,
163163
0x75, 0xb5, 0x45, 0x40, 0xf1, 0x37, 0x16, 0xc8,
164164
0x7b, 0x62, 0xe5, 0x1e, 0x2f, 0x4f, 0x22, 0xff,
165-
0xc2, 0x11, 0xdb, 0x48, 0x47, 0x9c, 0x2f, 0x54,
166-
0x6d, 0x52, 0xb0, 0x79, 0x55, 0xe7, 0x64, 0xeb,
167-
0x6a, 0x14, 0x2d, 0x57, 0x72, 0x45, 0xf4, 0x0a,
168-
0x44, 0xf5, 0xde, 0xe4, 0x68, 0xda, 0x42, 0x44,
165+
0xbf, 0x89, 0x13, 0xec, 0x53, 0x22, 0x6a, 0x34,
166+
0x89, 0x2d, 0x60, 0x25, 0x2a, 0x70, 0x52, 0x61,
167+
0x4c, 0xa7, 0x9a, 0xe9, 0x39, 0x98, 0x68, 0x28,
168+
0xd8, 0x1d, 0x23, 0x11, 0x95, 0x73, 0x71, 0xad,
169169
};
170170
size_t aggsig_len = sizeof(aggsig);
171171
size_t i;

0 commit comments

Comments
 (0)