FieldExtensions

Trait FieldExtensions 

Source
pub trait FieldExtensions {
    // Required methods
    fn try_sqrt(&self) -> Option<Self>
       where Self: Sized;
    fn legendre(&self) -> i32;
    fn order(&self) -> Option<BigInt>;

    // Provided method
    fn is_quadratic_residue(&self) -> bool { ... }
}
Expand description

Extension trait for optional field operations.

This trait provides operations that may not be available in all implementations or may have different performance characteristics.

Required Methods§

Source

fn try_sqrt(&self) -> Option<Self>
where Self: Sized,

Attempt to compute the square root.

Returns Some(sqrt) if a square root exists, None otherwise. This is an optional operation that may not be implemented by all backends.

Source

fn legendre(&self) -> i32

Compute the Legendre symbol (a/p).

Returns 1 if self is a quadratic residue, -1 if not, 0 if zero. This operation may be expensive and is provided as an extension.

Source

fn order(&self) -> Option<BigInt>

Get the order of this element (if it generates the field).

Returns the smallest positive integer d such that self^d ≡ 1 mod p. This is a potentially expensive operation.

Provided Methods§

Source

fn is_quadratic_residue(&self) -> bool

Check if this element is a quadratic residue.

Implementors§