Skip to content

module-lattice, ml-kem: introduce FixedWidthInt for compressed values#296

Open
MavenRain wants to merge 1 commit intoRustCrypto:masterfrom
MavenRain:fixed-width-int
Open

module-lattice, ml-kem: introduce FixedWidthInt for compressed values#296
MavenRain wants to merge 1 commit intoRustCrypto:masterfrom
MavenRain:fixed-width-int

Conversation

@MavenRain
Copy link
Copy Markdown

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.

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.
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.

ml-kem: Don't use FieldElement for compressed values

1 participant