Skip to content

Fix missing clears on secret values - #367

Open
mllwchrry wants to merge 1 commit into
BlockstreamResearch:masterfrom
mllwchrry:fix-missing-scalar-clear
Open

Fix missing clears on secret values#367
mllwchrry wants to merge 1 commit into
BlockstreamResearch:masterfrom
mllwchrry:fix-missing-scalar-clear

Conversation

@mllwchrry

Copy link
Copy Markdown
Collaborator

Several zkp module functions leave secret scalars and buffers live on the stack after use.
Adds the missing clears. Also removes a redundant prep clear in secp256k1_rangeproof_sign_impl that was already cleared earlier on the same path.

@DarkWindman DarkWindman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit. Everything else looks good to me!

secp256k1_scalar_set_int(&acc, 0);
for (i = 0; i < n; i++) {
secp256k1_scalar_set_b32(&x, blinds[i], &overflow);
if (overflow) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (overflow) {
secp256k1_scalar_clear(&acc);
secp256k1_scalar_clear(&x);
return 0;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e760fec.

@mllwchrry
mllwchrry force-pushed the fix-missing-scalar-clear branch from a9b681b to e760fec Compare July 13, 2026 15:08
@DarkWindman

Copy link
Copy Markdown
Contributor

ACK e760fec.

@real-or-random real-or-random left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK e760fec

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.

3 participants