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§
type Field: FieldTrait
Required Methods§
Implementations on Foreign Types§
Source§impl<E> FromField for Group<E>where
E: Environment,
impl<E> FromField for Group<E>where
E: Environment,
Source§impl<E> FromField for Scalar<E>where
E: Environment,
impl<E> FromField for Scalar<E>where
E: Environment,
Source§fn from_field(
field: &<Scalar<E> as FromField>::Field,
) -> Result<Scalar<E>, Error>
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:
- If the field element is larger than the scalar field modulus, then the operation will fail.
- 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 betweensize_in_data_bits < bits.len() < size_in_bits
.
- This is particularly useful for the case where a user called,
type Field = Field<E>
Source§impl<E, I> FromField for Integer<E, I>where
E: Environment,
I: IntegerType,
impl<E, I> FromField for Integer<E, I>where
E: Environment,
I: IntegerType,
Source§fn from_field(
field: &<Integer<E, I> as FromField>::Field,
) -> Result<Integer<E, I>, Error>
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:
- If the field element is larger than the integer domain, then the operation will fail.
- If the field element is smaller than the integer domain, then the operation will succeed.