Skip to content

Commit 6c03afa

Browse files
committed
overflow check in inc_aggregate
1 parent a469204 commit 6c03afa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/modules/schnorrsig/main_impl.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,14 @@ int secp256k1_schnorrsig_inc_aggregate(const secp256k1_context *ctx, unsigned ch
351351
hashcopy = hash;
352352
/* 1.c) Finalize the copy to get zi*/
353353
secp256k1_sha256_finalize(&hashcopy, hashoutput);
354+
/* Note: No need to check overflow, comes from hash */
354355
secp256k1_scalar_set_b32(&zi, hashoutput, NULL);
355356

356-
/* Step2: s := s + zi*si */
357-
secp256k1_scalar_set_b32(&si, &new_sigs64[(i-n_before)*64+32], NULL);
357+
/* Step 2: s := s + zi*si */
358+
secp256k1_scalar_set_b32(&si, &new_sigs64[(i-n_before)*64+32], &overflow);
359+
if (overflow) {
360+
return 0;
361+
}
358362
secp256k1_scalar_mul(&si, &si, &zi);
359363
secp256k1_scalar_add(&s, &s, &si);
360364
}

0 commit comments

Comments
 (0)