Skip to content

crypto.ecdsa: improves internal sign_digest routine - #23960

Merged
spytheman merged 2 commits into
vlang:masterfrom
blackshirt:optmz_sign
Mar 17, 2025
Merged

spytheman merged 2 commits into
vlang:masterfrom
blackshirt:optmz_sign

Conversation

@blackshirt

@blackshirt blackshirt commented Mar 17, 2025 •

Copy link
Copy Markdown
Contributor

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

@huly-for-github

Copy link
Copy Markdown

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

@spytheman spytheman 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.

Excellent work.

@spytheman
spytheman merged commit 1e5c812 into vlang:master Mar 17, 2025
@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