[][src]Trait zerocaf::traits::ops::SqrtRatioI

pub trait SqrtRatioI<T> {
    type Output;
#[must_use]
    fn sqrt_ratio_i(&self, v: T) -> Self::Output;
}

Associated Types

type Output

Loading content...

Required methods

#[must_use] fn sqrt_ratio_i(&self, v: T) -> Self::Output

Using the same trick as in ed25519 decoding, we merge the inversion, the square root, and the square test.AsMut

The first part of the return value signals whether u/v was square, and the second part contains a square root. Specifically, it returns:

  • (true, +sqrt(u/v)) if v is nonzero and u/v is square;
  • (true, zero) if u is zero;
  • (false, zero) if v is zero and uuu is nonzero;
  • (false, +sqrt(i*u/v)) if u/v is nonsquare (so iu/v is square).
Loading content...

Implementors

impl<'_> SqrtRatioI<&'_ FieldElement> for FieldElement[src]

type Output = (Choice, FieldElement)

fn sqrt_ratio_i(&self, v: &FieldElement) -> (Choice, FieldElement)[src]

The first part of the return value signals whether u/v was square, and the second part contains a square root. Specifically, it returns:

  • (true, +sqrt(u/v)) if v is nonzero and u/v is square;
  • (true, zero) if u is zero;
  • (false, zero) if v is zero and u is nonzero;
  • (false, +sqrt(i*u/v)) if u/v is nonsquare (so iu/v is square).
Loading content...