Skip to content

ARM64 assembly implementation for poly methods in the dilithium package.#561

Closed
elementrics wants to merge 5 commits intocloudflare:mainfrom
elementrics:main
Closed

ARM64 assembly implementation for poly methods in the dilithium package.#561
elementrics wants to merge 5 commits intocloudflare:mainfrom
elementrics:main

Conversation

@elementrics
Copy link
Copy Markdown
Contributor

Hi there! This is my first time being here!

A few weeks back I implemented the FIPS204 algorithm for my private project in go.

Due to the fact that I took inspiration from your implementation, I thought it's only fair to give back! Based on the fact that my implementation differs from your's in the end, I tried to provide some assembly implementation that should fit nicely in your package structure.

I ran all tests with "go test ./..." and also the affected package's tests. I also added some benchmarks for some common operations.

Feel free to give me some feedback. Also if you feel I made a mistake here to provide a PR, please let me know, so it wont happen again!

But should you feel the PR moves in the right direction, I can provide more assembly implementations in the future.

To be honest, this PR serves as an experiment to see if you guys are interested in what I am able to provide.

IMPORTANT: if I made some mistakes of any kind, just let me know!

Have a nice day!

@elementrics
Copy link
Copy Markdown
Contributor Author

To add some numbers: based on the benchmarks provided I saw a rough ~30% to 50% performance increase on my M1 Max.

@bwesterb
Copy link
Copy Markdown
Member

bwesterb commented Aug 14, 2025

Thanks for this! Reviewing cryptography takes a lot of time if done properly: almost as much as writing the code in the first place. I'd like to suggest you split up this PR into separate pieces. Some bits (eg. polyAdd) are quite easy to review, and we can land them quickly if one of us has some spare time in between. For the (Inv)NTT I'll need to find at least a free full day.

@elementrics
Copy link
Copy Markdown
Contributor Author

thanks for the quick response! I will try my best to split it up! Should everything go swimmingly, I am happy to provide more implementations in the future!

@bwesterb bwesterb self-assigned this Aug 14, 2025
@elementrics
Copy link
Copy Markdown
Contributor Author

elementrics commented Aug 14, 2025

I will create small PR's that capture the changes made by this PR. But you can keep this PR around, so for benchmarks etc. you can get a complete picture what the end result would be and if it is even worth it.

@elementrics
Copy link
Copy Markdown
Contributor Author

I will close the PR due to the fact that it is too big and also does not confirm with your guidelines. Some pieces will be presented in their own PR's later on.

@elementrics elementrics closed this Sep 1, 2025
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