Skip to content

hash: remove redundant secp256k1_sha256_initialize in tagged hash midstate functions#1825

Open
w0xlt wants to merge 1 commit intobitcoin-core:masterfrom
w0xlt:fix-redundant-sha256-initialize
Open

hash: remove redundant secp256k1_sha256_initialize in tagged hash midstate functions#1825
w0xlt wants to merge 1 commit intobitcoin-core:masterfrom
w0xlt:fix-redundant-sha256-initialize

Conversation

@w0xlt
Copy link

@w0xlt w0xlt commented Feb 17, 2026

Each tagged hash midstate function (e.g., secp256k1_schnorrsig_sha256_tagged) calls secp256k1_sha256_initialize before immediately overwriting every field it sets: s[0] through s[7] and bytes. The buf[64] member does not need initialization either, because bytes is set to 64, which means the buffer position (bytes & 0x3F) (= bytes % 64) is 0, so buf is always written before being read.

Remove the 11 redundant secp256k1_sha256_initialize calls across the schnorrsig, ellswift, and musig modules.

…tions

Each tagged hash midstate function (e.g., secp256k1_schnorrsig_sha256_tagged)
calls secp256k1_sha256_initialize before immediately overwriting every field
it sets: s[0] through s[7] and bytes. The buf[64] member does not need
initialization either, because bytes is set to 64, which means the buffer
position (bytes & 0x3F) is 0, so buf is always written before being read.

Remove the 11 redundant secp256k1_sha256_initialize calls across the
schnorrsig, ellswift, and musig modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant