pub trait FromField {
    type Field: FieldTrait;

    // Required method
    fn from_field(field: &Self::Field) -> Result<Self, Error>
       where Self: Sized;
}
Expand description

Unary operator for converting from a base field element.

Required Associated Types§

Required Methods§

source

fn from_field(field: &Self::Field) -> Result<Self, Error>
where Self: Sized,

Initializes an object from a base field element.

Implementations on Foreign Types§

§

impl<E> FromField for Group<E>
where E: Environment,

§

fn from_field(field: &<Group<E> as FromField>::Field) -> Result<Group<E>, Error>

Initializes a new group by recovering the x-coordinate of an affine group from a field element.

§

type Field = Field<E>

§

impl<E> FromField for Scalar<E>
where E: Environment,

§

fn from_field( field: &<Scalar<E> as FromField>::Field ) -> Result<Scalar<E>, Error>

Casts a scalar from a base field element.

This method guarantees the following:

  1. If the field element is larger than the scalar field modulus, then the operation will fail.
  2. If the field element is smaller than the scalar field modulus, then the operation will succeed. - This is particularly useful for the case where a user called, Scalar::from_field(scalar.to_field()), and the scalar bit representation is between size_in_data_bits < bits.len() < size_in_bits.
§

type Field = Field<E>

§

impl<E, I> FromField for Integer<E, I>
where E: Environment, I: IntegerType,

§

fn from_field( field: &<Integer<E, I> as FromField>::Field ) -> Result<Integer<E, I>, Error>

Casts an integer from a base field.

This method guarantees the following:

  1. If the field element is larger than the integer domain, then the operation will fail.
  2. If the field element is smaller than the integer domain, then the operation will succeed.
§

type Field = Field<E>

Implementors§