Skip to content

schnorrsig: Optimize negation in verification#1830

Closed
real-or-random wants to merge 1 commit intobitcoin-core:masterfrom
real-or-random:202602-schnorr-verify-negate
Closed

schnorrsig: Optimize negation in verification#1830
real-or-random wants to merge 1 commit intobitcoin-core:masterfrom
real-or-random:202602-schnorr-verify-negate

Conversation

@real-or-random
Copy link
Contributor

This trades a scalar negation for a group (= field) negation. This is admittedly more for fun because the actual improvement is hardly noticeable, but since it's in signature verification, I couldn't resist.

In fact, we could store the xonly pubkey as odd when we parse it, and save the negation entirely, but this adds complexity and I leave this to the next crazy contributor.

This trades a scalar negation for a group (= field) negation. This is
admittedly more for fun because the actual improvement is hardly
noticeable, but since it's in signature verification, I couldn't resist.

In fact, we could store the xonly pubkey as odd when we parse it, and
save the negation entirely, but this adds complexity and I leave this to
the next crazy contributor.
@real-or-random
Copy link
Contributor Author

scalar_neg takes about 2 ns on my laptop. fe_neg is much faster.

But damn, while I'm writing this I noticed that I overlooked the fe_normalize_weak call in gej_neg... Well, we could save that one in many cases, but this will add complexity, too. Nevermind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant