Skip to content

Commit 6361266

Browse files
committed
generator: speed up parsing
Similar to speeding up serialization; in our parsing logic we did a bunch of expensive stuff then expensively inverted it. Drop everything except the essential checks and then memcpy.
1 parent 5e7c2c1 commit 6361266

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/modules/generator/main_impl.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ static void secp256k1_pedersen_commitment_save(secp256k1_pedersen_commitment* co
276276

277277
int secp256k1_pedersen_commitment_parse(const secp256k1_context* ctx, secp256k1_pedersen_commitment* commit, const unsigned char *input) {
278278
secp256k1_fe x;
279-
secp256k1_ge ge;
280279

281280
VERIFY_CHECK(ctx != NULL);
282281
ARG_CHECK(commit != NULL);
@@ -285,13 +284,11 @@ int secp256k1_pedersen_commitment_parse(const secp256k1_context* ctx, secp256k1_
285284

286285
if ((input[0] & 0xFE) != 8 ||
287286
!secp256k1_fe_set_b32_limit(&x, &input[1]) ||
288-
!secp256k1_ge_set_xquad(&ge, &x)) {
287+
!secp256k1_ge_x_on_curve_var(&x)) {
289288
return 0;
290289
}
291-
if (input[0] & 1) {
292-
secp256k1_ge_neg(&ge, &ge);
293-
}
294-
secp256k1_pedersen_commitment_save(commit, &ge);
290+
291+
memcpy(commit->data, input, 33);
295292
return 1;
296293
}
297294

0 commit comments

Comments
 (0)