pub struct Interpolator<I, F> { /* private fields */ }Expand description
An interpolator allows recovering a polynomial’s constant from values.
This is useful for polynomial secret sharing. There, a secret is stored in the constant of a polynomial. Shares of the secret are created by evaluating the polynomial at various points. Given enough values for these points, the secret can be recovered.
Using an Interpolator can be more efficient, because work can be
done in advance based only on the points that will be used for recovery,
before the value of the polynomial at these points is known. The interpolator
can use these values to recover the secret at a later time.
§Usage
let interpolator = Interpolator::new([(0, p0), (1, p1)]);
assert_eq!(
Some(*f.constant()),
interpolator.interpolate(&[(0, f.eval(&p0)), (1, f.eval(&p1))].into_iter().try_collect().unwrap(), 1)
);
assert_eq!(
Some(*g.constant()),
interpolator.interpolate(&[(1, g.eval(&p1)), (0, g.eval(&p0))].into_iter().try_collect().unwrap(), 1)
);Implementations§
Source§impl<I: PartialEq, F: Ring> Interpolator<I, F>
impl<I: PartialEq, F: Ring> Interpolator<I, F>
Source§impl<I: Clone + Ord, F: Field> Interpolator<I, F>
impl<I: Clone + Ord, F: Field> Interpolator<I, F>
Sourcepub fn new(points: impl IntoIterator<Item = (I, F)>) -> Self
pub fn new(points: impl IntoIterator<Item = (I, F)>) -> Self
Create a new interpolator, given an association from indices to evaluation points.
If an index appears multiple times, the implementation is free to use any one of the evaluation points associated with that index. In other words, don’t do that, or ensure that if, for some reason, an index appears more than once, then it has the same evaluation point.
Auto Trait Implementations§
impl<I, F> Freeze for Interpolator<I, F>
impl<I, F> RefUnwindSafe for Interpolator<I, F>where
F: RefUnwindSafe,
I: RefUnwindSafe,
impl<I, F> Send for Interpolator<I, F>
impl<I, F> Sync for Interpolator<I, F>
impl<I, F> Unpin for Interpolator<I, F>
impl<I, F> UnwindSafe for Interpolator<I, F>where
F: UnwindSafe,
I: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more