Skip to main content

Poly

Struct Poly 

Source
pub struct Poly { /* private fields */ }
Expand description

A univariate polynomial in the prime field.

Implementations§

Source§

impl Poly

Source

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.

Source

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.

Source

pub fn zero() -> Self

Returns the polynomial with constant value 0.

Source

pub fn is_zero(&self) -> bool

Returns true if the polynomial is the constant value 0.

Source

pub fn one() -> Self

Returns the polynomial with constant value 1.

Source

pub fn constant(c: Fr) -> Self

Returns the polynomial with constant value c.

Source

pub fn identity() -> Self

Returns the identity function, i.e. the polynomial “x”.

Source

pub fn monomial(degree: usize) -> Self

Returns the (monic) monomial: x.pow(degree).

Source

pub fn interpolate<T, U, I>(samples_repr: I) -> Self
where 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)).

Source

pub fn degree(&self) -> usize

Returns the degree.

Source

pub fn evaluate<T: IntoFr>(&self, i: T) -> Fr

Returns the value at the point i.

Source

pub fn commitment(&self) -> Commitment

Returns the corresponding commitment.

Source

pub fn reveal(&self) -> String

Generates a non-redacted debug string. This method differs from the Debug implementation in that it does leak the secret prime field elements.

Trait Implementations§

Source§

impl<'a, B: Borrow<Poly>> Add<B> for &'a Poly

Source§

type Output = Poly

The resulting type after applying the + operator.
Source§

fn add(self, rhs: B) -> Poly

Performs the + operation. Read more
Source§

impl<B: Borrow<Poly>> Add<B> for Poly

Source§

type Output = Poly

The resulting type after applying the + operator.
Source§

fn add(self, rhs: B) -> Poly

Performs the + operation. Read more
Source§

impl<'a> Add<Fr> for Poly

Source§

type Output = Poly

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Fr) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<u64> for Poly

Source§

type Output = Poly

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
Source§

impl<B: Borrow<Poly>> AddAssign<B> for Poly

Source§

fn add_assign(&mut self, rhs: B)

Performs the += operation. Read more
Source§

impl Clone for Poly

Creates a new Poly with the same coefficients as another polynomial.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Poly

A debug statement where the coeff vector of prime field elements has been redacted.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Poly

Source§

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 Poly

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Poly

Source§

impl From<Poly> for SecretKeySet

Source§

fn from(poly: Poly) -> SecretKeySet

Converts to this type from the input type.
Source§

impl From<Vec<Fr>> for Poly

Creates a new Poly instance from a vector of prime field elements representing the coefficients of the polynomial.

Source§

fn from(coeff: Vec<Fr>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Mul<&'a Fr> for Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Fr) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a Fr> for &'a Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Fr) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, B: Borrow<Poly>> Mul<B> for &'a Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: B) -> Self::Output

Performs the * operation. Read more
Source§

impl<B: Borrow<Poly>> Mul<B> for Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: B) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Fr> for Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Fr) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<Fr> for &'a Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Fr) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for Poly

Source§

type Output = Poly

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl<B: Borrow<Self>> MulAssign<B> for Poly

Source§

fn mul_assign(&mut self, rhs: B)

Performs the *= operation. Read more
Source§

impl MulAssign<Fr> for Poly

Source§

fn mul_assign(&mut self, rhs: Fr)

Performs the *= operation. Read more
Source§

impl PartialEq for Poly

Source§

fn eq(&self, other: &Poly) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Poly

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Poly

Source§

impl<'a, B: Borrow<Poly>> Sub<B> for &'a Poly

Source§

type Output = Poly

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: B) -> Poly

Performs the - operation. Read more
Source§

impl<B: Borrow<Poly>> Sub<B> for Poly

Source§

type Output = Poly

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: B) -> Poly

Performs the - operation. Read more
Source§

impl<'a> Sub<Fr> for Poly

Source§

type Output = Poly

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Fr) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<u64> for Poly

Source§

type Output = Poly

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u64) -> Self::Output

Performs the - operation. Read more
Source§

impl<B: Borrow<Poly>> SubAssign<B> for Poly

Source§

fn sub_assign(&mut self, rhs: B)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl Freeze for Poly

§

impl RefUnwindSafe for Poly

§

impl Send for Poly

§

impl Sync for Poly

§

impl Unpin for Poly

§

impl UnsafeUnpin for Poly

§

impl UnwindSafe for Poly

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.