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§
§impl<E> FromField for Scalar<E>where
    E: Environment,
 
impl<E> FromField for Scalar<E>where E: Environment,
§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.