module-lattice, ml-kem: introduce FixedWidthInt for compressed values#296
Open
MavenRain wants to merge 1 commit intoRustCrypto:masterfrom
Open
module-lattice, ml-kem: introduce FixedWidthInt for compressed values#296MavenRain wants to merge 1 commit intoRustCrypto:masterfrom
MavenRain wants to merge 1 commit intoRustCrypto:masterfrom
Conversation
Per RustCrypto#26, the codomain of FIPS 203's Compress_d is the integer ring Z_{2^d}, not the prime field Z_q. Reusing Elem<F> for both lets the Barrett-reduced Mul on Elem be applied to compressed values where it is meaningless. Adds FixedWidthInt<F, D>, FixedWidthPolynomial<F, D>, and FixedWidthVector<F, K, D> in module-lattice, plus a PrimeField: Field marker trait that gates Mul on Elem/Polynomial/Vector/NttPolynomial. ml-kem's mutating Compress trait is replaced with consuming Compress<D>/Decompress<D> traits that move between the prime-field types and the new fixed-width types, threading the typed boundary through K-PKE.Encrypt and K-PKE.Decrypt. Closes RustCrypto#26.
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.
Per #26, the codomain of FIPS 203's Compress_d is the integer ring Z_{2^d}, not the prime field Z_q. Reusing Elem for both lets the Barrett-reduced Mul on Elem be applied to compressed values where it is meaningless.
Adds FixedWidthInt<F, D>, FixedWidthPolynomial<F, D>, and FixedWidthVector<F, K, D> in module-lattice, plus a PrimeField: Field marker trait that gates Mul on Elem/Polynomial/Vector/NttPolynomial. ml-kem's mutating Compress trait is replaced with consuming Compress/Decompress traits that move between the prime-field types and the new fixed-width types, threading the typed boundary through K-PKE.Encrypt and K-PKE.Decrypt.
Closes #26.