Skip to content

x.crypto.ascon: improves the core of Ascon permutation routine#25278

Merged
spytheman merged 4 commits into
vlang:masterfrom
blackshirt:ascon_opt
Sep 11, 2025
Merged

x.crypto.ascon: improves the core of Ascon permutation routine#25278
spytheman merged 4 commits into
vlang:masterfrom
blackshirt:ascon_opt

Conversation

@blackshirt

@blackshirt blackshirt commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

This PR improves the core of x.crypto.ascon permutation routine in the mean of internal routine ascon_pnr function.
After some profiling, the most widely called routines was 3 function of the core permutation routines, ie, ascon_pnr, ascon_perm and utility ascon_rotate_right used in permutation.
The number before patch using sum256 as a test case:

== Before patch ==
Benchmarking ascon.sum256 before patch ...
Average time ascon.sum256 before patch: 11 µs

And here the number after patch

== After patch ==
Benchmarking ascon.sum256 after patch ...
Average time ascon.sum256 after patch: 6 µs

Nearly 50% improvement in performance was a good addition. The numbers i talk on Discord confirm this approach.

This patch fundamentally unifies ascon_pnr and ascon_perm into single one routine. Its also embed directly bits rotate right logic onto this single routine and improves all performances.
This patch also contains some small cleans up, updates readme file. and other small thing.

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-25145

@blackshirt blackshirt changed the title x.crypto.ascon: improves performance and cleans up a bits x.crypto.ascon: improves ascon permutation routine Sep 10, 2025
@blackshirt blackshirt changed the title x.crypto.ascon: improves ascon permutation routine x.crypto.ascon: improves the core of Ascon permutation routine Sep 10, 2025
Comment thread vlib/x/crypto/ascon/aead128_test.v Outdated
@spytheman

Copy link
Copy Markdown
Contributor

You can add the code that you run for the benches in the bench/crypto folder or in vlib/x/crypto/ascon/bench/ . That way it can be run by everyone, interested in changing the module in the future.

@blackshirt

Copy link
Copy Markdown
Contributor Author

You can add the code that you run for the benches in the bench/crypto folder or in vlib/x/crypto/ascon/bench/ . That way it can be run by everyone, interested in changing the module in the future.

Okey .. i would add it in next time of cycles.Its on plan

@spytheman

Copy link
Copy Markdown
Contributor

Okey .. i would add it in next time of cycles.Its on plan

Thank you 🙇🏻 .

@spytheman spytheman merged commit f16452d into vlang:master Sep 11, 2025
72 checks passed
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