Struct threshold_crypto::poly::Poly
source · pub struct Poly { /* private fields */ }
Expand description
A univariate polynomial in the prime field.
Implementations§
source§impl Poly
impl Poly
sourcepub fn random<R: Rng>(degree: usize, rng: &mut R) -> Self
pub fn random<R: Rng>(degree: usize, rng: &mut R) -> Self
Creates a random polynomial.
Panics
Panics if the degree
is too large for the coefficients to fit into a Vec
.
sourcepub fn try_random<R: Rng>(degree: usize, rng: &mut R) -> Result<Self>
pub fn try_random<R: Rng>(degree: usize, rng: &mut R) -> Result<Self>
Creates a random polynomial. This constructor is identical to the Poly::random()
constructor in every way except that this constructor will return an Err
where
try_random
would return an error.
sourcepub fn interpolate<T, U, I>(samples_repr: I) -> Selfwhere
I: IntoIterator<Item = (T, U)>,
T: IntoFr,
U: IntoFr,
pub fn interpolate<T, U, I>(samples_repr: I) -> Selfwhere
I: IntoIterator<Item = (T, U)>,
T: IntoFr,
U: IntoFr,
Returns the unique polynomial f
of degree samples.len() - 1
with the given values
(x, f(x))
.
sourcepub fn commitment(&self) -> Commitment
pub fn commitment(&self) -> Commitment
Returns the corresponding commitment.
Trait Implementations§
source§impl<B: Borrow<Poly>> AddAssign<B> for Poly
impl<B: Borrow<Poly>> AddAssign<B> for Poly
source§fn add_assign(&mut self, rhs: B)
fn add_assign(&mut self, rhs: B)
Performs the
+=
operation. Read moresource§impl Debug for Poly
impl Debug for Poly
A debug statement where the coeff
vector of prime field elements has been redacted.
source§impl<'de> Deserialize<'de> for Poly
impl<'de> Deserialize<'de> for Poly
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 From<Poly> for SecretKeySet
impl From<Poly> for SecretKeySet
source§fn from(poly: Poly) -> SecretKeySet
fn from(poly: Poly) -> SecretKeySet
Converts to this type from the input type.
source§impl From<Vec<Fr, Global>> for Poly
impl From<Vec<Fr, Global>> for Poly
Creates a new Poly
instance from a vector of prime field elements representing the
coefficients of the polynomial.
source§impl<B: Borrow<Self>> MulAssign<B> for Poly
impl<B: Borrow<Self>> MulAssign<B> for Poly
source§fn mul_assign(&mut self, rhs: B)
fn mul_assign(&mut self, rhs: B)
Performs the
*=
operation. Read moresource§impl MulAssign<Fr> for Poly
impl MulAssign<Fr> for Poly
source§fn mul_assign(&mut self, rhs: Fr)
fn mul_assign(&mut self, rhs: Fr)
Performs the
*=
operation. Read moresource§impl<B: Borrow<Poly>> SubAssign<B> for Poly
impl<B: Borrow<Poly>> SubAssign<B> for Poly
source§fn sub_assign(&mut self, rhs: B)
fn sub_assign(&mut self, rhs: B)
Performs the
-=
operation. Read more