pub struct RingElement { /* private fields */ }Expand description
Polynomial ring element Z_q[X]/(X^n + 1).
Holds RLWE secret-key coefficients. Memory is zeroed on Drop so a
dropped RingElement cannot leak its secret via a core dump or
swap-to-disk event (NIST SP 800-171 § 3.13.10).
Implementations§
Source§impl RingElement
impl RingElement
pub fn new(n: usize, q: u64) -> Self
pub fn random(n: usize, q: u64, rng: &mut StdRng) -> Self
pub fn random_ternary(n: usize, q: u64, rng: &mut StdRng) -> Self
pub fn random_gaussian(n: usize, q: u64, sigma: f64, rng: &mut StdRng) -> Self
pub fn from_bytes(bytes: &[u8], n: usize, q: u64) -> Self
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Sourcepub fn mul(&self, other: &RingElement) -> RingElement
pub fn mul(&self, other: &RingElement) -> RingElement
Polynomial multiplication in R_q = Z_q[X]/(X^n + 1)
Sourcepub fn add(&self, other: &RingElement) -> RingElement
pub fn add(&self, other: &RingElement) -> RingElement
Polynomial addition
Sourcepub fn sub(&self, other: &RingElement) -> RingElement
pub fn sub(&self, other: &RingElement) -> RingElement
Polynomial subtraction
Sourcepub fn scale(&self, scalar: i64) -> RingElement
pub fn scale(&self, scalar: i64) -> RingElement
Scale coefficients
Trait Implementations§
Source§impl Clone for RingElement
impl Clone for RingElement
Source§fn clone(&self) -> RingElement
fn clone(&self) -> RingElement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RingElement
impl Debug for RingElement
Source§impl<'de> Deserialize<'de> for RingElement
impl<'de> Deserialize<'de> for RingElement
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Drop for RingElement
impl Drop for RingElement
Source§impl Serialize for RingElement
impl Serialize for RingElement
Auto Trait Implementations§
impl Freeze for RingElement
impl RefUnwindSafe for RingElement
impl Send for RingElement
impl Sync for RingElement
impl Unpin for RingElement
impl UnsafeUnpin for RingElement
impl UnwindSafe for RingElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more