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

crypto.ecdsa: improves internal sign_digest routine #23960

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

blackshirt
Copy link
Contributor

@blackshirt blackshirt commented Mar 17, 2025

This PR improves sign_digest internal routine used by PrivateKey.sign method. Its done by eleminating one step of C.EVP_PKEY_sign calls with null signature buffer to know the length (size) of required buffer. This maximal sizes of the buffer was already known by calling C.EVP_PKEY_size, so its not needed to call C.EVP_PKEY_sign just to know the size of required buffer and we can allocate the buffer instead and call C.EVP_PKEY_sign directly with this allocated buffer.

In my benchmark test, there are small improvements on this part

Benchmarking PrivateKey.sign() (before patch)...
Average PrivateKey.sign() (before patch) time: 37 µs

and after patch

Benchmarking PrivateKey.sign() (after patch)...
Average PrivateKey.sign() (after patch) time: 27 µs

Thanks

Copy link

Connected to Huly®: V_0.6-22355

@blackshirt blackshirt changed the title crypto.ecdsa: optimize nternal sign_digest routine crypto.ecdsa: optimize nternal sign_digest routine Mar 17, 2025
@blackshirt blackshirt changed the title crypto.ecdsa: optimize nternal sign_digest routine crypto.ecdsa: optimize internal sign_digest routine Mar 17, 2025
@blackshirt blackshirt changed the title crypto.ecdsa: optimize internal sign_digest routine crypto.ecdsa: improves internal sign_digest routine Mar 17, 2025
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 1e5c812 into vlang:master Mar 17, 2025
68 checks passed
@blackshirt blackshirt deleted the optmz_sign branch March 18, 2025 00:38
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.

2 participants