v0.18.0: Implementation of generic newtypes#615
Merged
Conversation
… generic-newtypes
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v0.18.0 #615 +/- ##
===========================================
+ Coverage 99.14% 99.24% +0.09%
===========================================
Files 108 113 +5
Lines 19957 21243 +1286
===========================================
+ Hits 19787 21082 +1295
+ Misses 170 161 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #249 #274
First and by far the largest set of breaking changes for version
0.18.0. A re-design of the newtypes used across the library has been a long time coming, at least since #249 and work started in #274. The work behind this new interface has largely been done by @vlmutolo in #274 and this PR uses the same interface, with a few tweaks.The new interface includes:
Public<T: TypeSpec>andSecret<T: TypeSpec>where the public traitTypeSpecis implemented for zero-sized structs to contextualize the uses across different primitives/schemes.Public<T>andSecret<T>can additionally implementGenerateSecret/GeneratePublicto indicate that either one can be generated using a CSPRNG, within a given context. A major change here is also that all randomness-generation has become fallible. There is noDefaultthat panics and there is nogenerate()that panics. This has been motivated by an effort to use it without hiding possiblepanic!()s and making auditing hereof easier.The generalized approach offers much more flexibility for current and future types to be added. A good example is that the previous newtypes weren't usable to ML-KEM encapsulation/decapsulation keys due to additional checking requirements, etc. This generalized approach has allowed us to implement it for these as well. The result is also a more consistent API experience across different parts of the library.
Finally, removing the use of macros has reduced code-expansion from this, amount of duplicate tests being run (for newtypes having the same underlying primitive/sizes, etc.).
The amount of changes here justify a new "Discussion" for
v0.18.0that includes a migration guide.