pub struct Poly<C>(/* private fields */);Expand description
A polynomial that is using a scalar for the variable x and a generic element for the coefficients. The coefficients must be able to multiply the type of the variable, which is always a scalar.
Implementations§
Source§impl<C: Element> Poly<C>
impl<C: Element> Poly<C>
Sourcepub fn new_from<R: RngCore>(degree: usize, rng: &mut R) -> Self
pub fn new_from<R: RngCore>(degree: usize, rng: &mut R) -> Self
Returns a new polynomial of the given degree where each coefficients is sampled at random from the given RNG. In the context of secret sharing, the threshold is the degree + 1.
Sourcepub fn get(&self, i: Idx) -> C
pub fn get(&self, i: Idx) -> C
get returns the given coefficient at the requested index. It will panic
if the index is out of range,i.e. if i > self.degree().
Sourcepub fn set(&mut self, index: usize, value: C)
pub fn set(&mut self, index: usize, value: C)
set the given element at the specified index. The index 0 is the free coefficient of the polynomial. It panics if the index is out of range.
Source§impl<C> Poly<C>
impl<C> Poly<C>
Sourcepub fn recover(t: usize, shares: Vec<Eval<C>>) -> Result<C, PolyError>
pub fn recover(t: usize, shares: Vec<Eval<C>>) -> Result<C, PolyError>
Given at least t polynomial evaluations, it will recover the polynomial’s
constant term
Sourcepub fn full_recover(t: usize, shares: Vec<Eval<C>>) -> Result<Self, PolyError>
pub fn full_recover(t: usize, shares: Vec<Eval<C>>) -> Result<Self, PolyError>
Given at least t polynomial evaluations, it will recover the entire polynomial
Sourcepub fn public_key(&self) -> &C
pub fn public_key(&self) -> &C
Returns the constant term of the polynomial which can be interpreted as the threshold public key