Skip to content

Commit fc2f847

Browse files
committed
remove needless save/load
1 parent 7222e05 commit fc2f847

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/secp256k1.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ int secp256k1_ecdsa_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature
486486
}
487487

488488
/* Compute an ec commitment tweak as hash(pubkey, data). */
489-
static int secp256k1_ec_commit_tweak(const secp256k1_context *ctx, unsigned char *tweak32, const secp256k1_pubkey *pubkey, const unsigned char *data, size_t data_size) {
490-
secp256k1_ge p;
489+
static int secp256k1_ec_commit_tweak(unsigned char *tweak32, const secp256k1_ge *pubkey, const unsigned char *data, size_t data_size) {
490+
secp256k1_ge p = *pubkey;
491491
unsigned char rbuf[33];
492492
size_t rbuf_size = sizeof(rbuf);
493493
secp256k1_sha256 sha;
@@ -496,9 +496,6 @@ static int secp256k1_ec_commit_tweak(const secp256k1_context *ctx, unsigned char
496496
/* That's probably not what the caller wanted */
497497
return 0;
498498
}
499-
if(!secp256k1_pubkey_load(ctx, &p, pubkey)) {
500-
return 0;
501-
}
502499
secp256k1_eckey_pubkey_serialize(&p, rbuf, &rbuf_size, 1);
503500

504501
secp256k1_sha256_initialize(&sha);
@@ -517,11 +514,9 @@ static int secp256k1_ec_commit_tweak_from_seckey(
517514
size_t data_size) {
518515
secp256k1_gej rp;
519516
secp256k1_ge r;
520-
secp256k1_pubkey pubkey_tmp;
521517
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rp, seckey);
522518
secp256k1_ge_set_gej(&r, &rp);
523-
secp256k1_pubkey_save(&pubkey_tmp, &r);
524-
return secp256k1_ec_commit_tweak(ctx, tweak32, &pubkey_tmp, data, data_size);
519+
return secp256k1_ec_commit_tweak(tweak32, &r, data, data_size);
525520
}
526521

527522
int secp256k1_ecdsa_sign_to_contract(const secp256k1_context* ctx, secp256k1_ecdsa_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata, const unsigned char* s2c_data32) {

0 commit comments

Comments
 (0)