Skip to content

Commit 8faa785

Browse files
glslangLawrence Nahum
authored andcommitted
avoid unnecessary memmove
1 parent 1f71641 commit 8faa785

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/sign.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,12 @@ int wally_ec_sig_from_bytes(const unsigned char *priv_key, size_t priv_key_len,
248248
}
249249

250250
/* Note this function is documented as never failing */
251-
secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, bytes_out, &recid, &sig_secp);
251+
secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, flags & EC_FLAG_RECOVERABLE ? bytes_out + 1 : bytes_out, &recid, &sig_secp);
252252

253253
if (!(flags & EC_FLAG_GRIND_R) || bytes_out[0] < 0x80) {
254254
wally_clear(&sig_secp, sizeof(sig_secp));
255255
/* Note the following assumes the key is compressed */
256256
if (flags & EC_FLAG_RECOVERABLE) {
257-
memmove(&bytes_out[1], &bytes_out[0], EC_SIGNATURE_LEN);
258257
bytes_out[0] = 27 + recid + 4;
259258
}
260259

0 commit comments

Comments
 (0)