pub struct Polynomial {
pub coeffs: [i16; 256],
}Expand description
A polynomial over the ML-KEM ring.
Dev note: The following structure does not necessarily need to be declared as public. There is no real scenario where this function needs to be called directly. However, in order to test the Debug and Display traits, it is necessary to use STD, so those can’t be tested from inline tests in this file and the real unit tests are in a different crate. That’s the reason why pub is used.
§🚨 Security 🚨
Polynomials themselves are not inherently secret since sometimes they are part of public keys
and sometimes private keys.
It is the responsibility of the caller to wrap sensitive instances in Secret<Vector>.
Fields§
§coeffs: [i16; 256]Note: this is exposed publicly only for testing purposes and there is no good reason to use it in production code.
Implementations§
Source§impl Polynomial
impl Polynomial
Sourcepub fn ntt(&mut self)
pub fn ntt(&mut self)
Algorithm 9 NTT(𝑓) Computes the NTT representation 𝑓_hat of the given polynomial 𝑓 ∈ 𝑅𝑞. Input: array 𝑓 ∈ ℤ256 ▷ the coefficients of the input polynomial Output: array 𝑓_hat ∈ ℤ256 ▷ the coefficients of the NTT of the input polynomial Note: this is exposed publicly only for testing purposes and there is no good reason to use it in production code.
Sourcepub fn inv_ntt(&mut self)
pub fn inv_ntt(&mut self)
Algorithm 10 NTT (𝑓_hat) Computes the polynomial 𝑓 ∈ 𝑅𝑞 that corresponds to the given NTT representation 𝑓 ∈ 𝑇𝑞. Input: array 𝑓 ∈ ℤ_{256} ▷ the coefficients of input NTT representation Output: array 𝑓 ∈ ℤ_{256} ▷ the coefficients of the inverse NTT of the input Note: this is exposed publicly only for testing purposes and there is no good reason to use it in production code.
Trait Implementations§
Source§impl Clone for Polynomial
impl Clone for Polynomial
Source§fn clone(&self) -> Polynomial
fn clone(&self) -> Polynomial
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Index<usize> for Polynomial
Convenience function to avoid “.0” all over the place.
impl Index<usize> for Polynomial
Convenience function to avoid “.0” all over the place.
Source§impl IndexMut<usize> for Polynomial
Convenience function to avoid “.0” all over the place.
impl IndexMut<usize> for Polynomial
Convenience function to avoid “.0” all over the place.