WordPress at Your Fingertips
function is not described

ParagonIE_Sodium_Core_Ristretto255::ristretto255_sqrt_ratio_m1() public WP 1.0

{} It's a method of the class: ParagonIE_Sodium_Core_Ristretto255{}

No Hooks.

Return

Array{x:. ParagonIE_Sodium_Core_Curve25519_Fe, nonsquare: int}

Usage

$result = ParagonIE_Sodium_Core_Ristretto255::ristretto255_sqrt_ratio_m1(;

Code of ParagonIE_Sodium_Core_Ristretto255::ristretto255_sqrt_ratio_m1() WP 5.8.2

public static function ristretto255_sqrt_ratio_m1(
    ParagonIE_Sodium_Core_Curve25519_Fe $u,
    ParagonIE_Sodium_Core_Curve25519_Fe $v
) {
    $sqrtm1 = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$sqrtm1);

    $v3 = self::fe_mul(
        self::fe_sq($v),
        $v
    ); /* v3 = v^3 */
    $x = self::fe_mul(
        self::fe_mul(
            self::fe_sq($v3),
            $u
        ),
        $v
    ); /* x = uv^7 */

    $x = self::fe_mul(
        self::fe_mul(
            self::fe_pow22523($x), /* x = (uv^7)^((q-5)/8) */
            $v3
        ),
        $u
    ); /* x = uv^3(uv^7)^((q-5)/8) */

    $vxx = self::fe_mul(
        self::fe_sq($x),
        $v
    ); /* vx^2 */

    $m_root_check = self::fe_sub($vxx, $u); /* vx^2-u */
    $p_root_check = self::fe_add($vxx, $u); /* vx^2+u */
    $f_root_check = self::fe_mul($u, $sqrtm1); /* u*sqrt(-1) */
    $f_root_check = self::fe_add($vxx, $f_root_check); /* vx^2+u*sqrt(-1) */

    $has_m_root = self::fe_iszero($m_root_check);
    $has_p_root = self::fe_iszero($p_root_check);
    $has_f_root = self::fe_iszero($f_root_check);

    $x_sqrtm1 = self::fe_mul($x, $sqrtm1); /* x*sqrt(-1) */

    $x = self::fe_abs(
        self::fe_cmov($x, $x_sqrtm1, $has_p_root | $has_f_root)
    );
    return array(
        'x' => $x,
        'nonsquare' => $has_m_root | $has_p_root
    );
}