Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txscript: Optimize sig enc check with mod n scalar. #2246

Merged
merged 2 commits into from
Jul 12, 2020

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jul 7, 2020

This requires #2244.

This modifies the signature encoding check function to use the new secp256k1.ModNScalar type for the half order check instead of a big int.

The following benchmark shows a before and after comparison of a typical signature encoding check:

benchmark                         old ns/op    new ns/op    delta
-------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   79.0         46.9         -40.63%

benchmark                         old allocs   new allocs   delta
--------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   1            0            -100.00%

benchmark                         old bytes    new bytes    delta
--------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   64           0            -100.00%

@davecgh davecgh added this to the 1.6.0 milestone Jul 7, 2020
Copy link
Member

@dnldd dnldd left a comment

Choose a reason for hiding this comment

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

Looks good.

@davecgh davecgh force-pushed the txscript_checksigencoding_modnscalar branch from 595b9d0 to a82d8d7 Compare July 9, 2020 01:14
This modifies the signature encoding check function to use the new
secp256k1.ModNScalar type for the half order check instead of a big int.

The following benchmark shows a before and after comparison of a typical
signature encoding check:

benchmark                         old ns/op    new ns/op    delta
-------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   79.0         46.9         -40.63%

benchmark                         old allocs   new allocs   delta
--------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   1            0            -100.00%

benchmark                         old bytes    new bytes    delta
--------------------------------------------------------------------
BenchmarkCheckSignatureEncoding   64           0            -100.00%
@davecgh davecgh force-pushed the txscript_checksigencoding_modnscalar branch from a82d8d7 to f7e984b Compare July 12, 2020 05:58
@davecgh davecgh merged commit f7e984b into decred:master Jul 12, 2020
@davecgh davecgh deleted the txscript_checksigencoding_modnscalar branch July 12, 2020 06:07
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.

4 participants