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

Refactor: Kyber internals #3887

Merged
merged 2 commits into from
Apr 19, 2024
Merged

Conversation

reneme
Copy link
Collaborator

@reneme reneme commented Jan 16, 2024

This is an iteration of the Kyber internals, in preparation of an ML-KEM implementation. Also, it retrofits the helpers we added along the way in the last two years. Most notably: BufferStuffer and BufferSlicer and Strong<> types. Especially the strong types made it possible to restrict the "symmetric algorithms" in kyber_symmetric_primitives.h.

Before, most of the algorithm (i.e. the Polynomial structures) was hidden away in the kyber.cpp compilation unit in the kyber_common module. For added flexibility, I restructured the code into a few distinct header and implementation files. Also, the kyber and kyber_90s modules now moved inside a new internal kyber_round3 module. These changes make room for an upcoming ML-KEM-ipd implementation that reuses as much of the implementation as possible.

The public interface isn't affected by any of those changes.

@reneme reneme added this to the Botan 3.4.0 milestone Jan 16, 2024
@reneme reneme self-assigned this Jan 16, 2024
@coveralls
Copy link

coveralls commented Jan 16, 2024

Coverage Status

coverage: 92.027% (-0.004%) from 92.031%
when pulling a630490 on Rohde-Schwarz:refactor/kyber
into 11b88e5 on randombit:master.

@reneme
Copy link
Collaborator Author

reneme commented Jan 17, 2024

Force-pushed after #3888, to fix CI.

@reneme reneme marked this pull request as draft January 17, 2024 07:13
Copy link
Collaborator

@FAlbertDev FAlbertDev left a comment

Choose a reason for hiding this comment

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

I really like Kyber with strong types! Also, the buffer stuffer fits very well. No more nasty pointer arithmetic 🎉

src/lib/pubkey/kyber/kyber_common/kyber.cpp Outdated Show resolved Hide resolved
src/lib/pubkey/kyber/kyber_common/kyber.cpp Outdated Show resolved Hide resolved
src/lib/pubkey/kyber/kyber_common/kyber.cpp Show resolved Hide resolved
src/lib/pubkey/kyber/kyber_common/kyber.cpp Outdated Show resolved Hide resolved
@reneme reneme force-pushed the refactor/kyber branch 3 times, most recently from 95143b8 to 3fc1233 Compare January 18, 2024 12:55
@reneme reneme marked this pull request as ready for review January 18, 2024 14:43
@reneme reneme requested a review from FAlbertDev January 18, 2024 14:44
This was referenced Jan 18, 2024
Copy link
Collaborator

@FAlbertDev FAlbertDev left a comment

Choose a reason for hiding this comment

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

Nice! I have the code on my left and the FIPS 203 spec on my right screen, and can easily compare it 👍

src/lib/pubkey/kyber/kyber_common/kyber_keys.cpp Outdated Show resolved Hide resolved
src/lib/pubkey/kyber/kyber_common/kyber_keys.cpp Outdated Show resolved Hide resolved
@reneme
Copy link
Collaborator Author

reneme commented Feb 16, 2024

Rebased and resolved conflicts after #3874 got merged.

Copy link
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

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

Very nice 👍

@reneme
Copy link
Collaborator Author

reneme commented Mar 19, 2024

Thanks for the review! We have a further iteration for this in the pipeline, though.

It'll be a few weeks before we're done with it, unfortunately. Currently busy preparing the concluding workshop for BSI's project 481.

@reneme
Copy link
Collaborator Author

reneme commented Apr 19, 2024

Resolved a conflict with master.

reneme added 2 commits April 19, 2024 12:52
* BufferStuff/Slicer
* Strong types
* Prepare for introduction of ML-KEM (ipd)
* introduce nomenclature of FIPS 203
@reneme
Copy link
Collaborator Author

reneme commented Apr 19, 2024

I realized that the planned changes, I mentioned last month, can be easily added on top of this. So, let's merge this now and we'll continue working on master.

@reneme reneme merged commit b1a6d25 into randombit:master Apr 19, 2024
43 checks passed
@reneme reneme deleted the refactor/kyber branch April 19, 2024 14:45
reneme added a commit to sehlen-bsi/botan-docs that referenced this pull request Jul 2, 2024
See: randombit/botan#3887

This is a fairly minimal adaption, once the full refactoring
is merged, we'll have to rewrite this more substantially. That won't
happen before Botan 3.5.0, though.

See also: randombit/botan#4024
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