fe_tobytes example

        self::fe_cswap($x2$x3$swap);

        # fe_cswap(z2,z3,swap);         self::fe_cswap($z2$z3$swap);

        # fe_invert(z2,z2);         $z2 = self::fe_invert($z2);

        # fe_mul(x2,x2,z2);         $x2 = self::fe_mul($x2$z2);
        # fe_tobytes(q,x2);         return self::fe_tobytes($x2);
    }

    /** * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core_Curve25519_Fe $edwardsY * @param ParagonIE_Sodium_Core_Curve25519_Fe $edwardsZ * @return ParagonIE_Sodium_Core_Curve25519_Fe */
    public static function edwards_to_montgomery(
        ParagonIE_Sodium_Core_Curve25519_Fe $edwardsY,
        


        # fe_1(x);         # fe_add(x, x, A.Y);         # fe_mul(x, x, one_minus_y);         $x = self::fe_mul(
            self::fe_add(self::fe_1()$A->Y),
            $one_minux_y
        );

        # fe_tobytes(curve25519_pk, x);         return self::fe_tobytes($x);
    }

    /** * @internal You should not use this directly from another application * * @param string $sk * @return string * @throws SodiumException * @throws TypeError */
    public static function sk_to_pk($sk)
    {

    public static function fe_isnegative(ParagonIE_Sodium_Core_Curve25519_Fe $f)
    {
        $str = self::fe_tobytes($f);
        return (int) (self::chrToInt($str[0]) & 1);
    }

    /** * Returns 0 if this field element results in all NUL bytes. * * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core_Curve25519_Fe $f * @return bool * @throws SodiumException * @throws TypeError */
        self::fe_cswap($x2$x3$swap);

        # fe_cswap(z2,z3,swap);         self::fe_cswap($z2$z3$swap);

        # fe_invert(z2,z2);         $z2 = self::fe_invert($z2);

        # fe_mul(x2,x2,z2);         $x2 = self::fe_mul($x2$z2);
        # fe_tobytes(q,x2);         return (string) self::fe_tobytes($x2);
    }

    /** * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ * @return ParagonIE_Sodium_Core32_Curve25519_Fe * @throws SodiumException * @throws TypeError */
    

    public static function fe_iszero(ParagonIE_Sodium_Core_Curve25519_Fe $f)
    {
        static $zero;
        if ($zero === null) {
            $zero = str_repeat("\x00", 32);
        }
        /** @var string $zero */
        $str = self::fe_tobytes($f);

        $d = 0;
        for ($i = 0; $i < 32; ++$i) {
            $d |= self::chrToInt($str[$i]);
        }
        return (($d - 1) >> 31) & 1;
    }


    /** * @param ParagonIE_Sodium_Core_Curve25519_Fe $u * @param ParagonIE_Sodium_Core_Curve25519_Fe $v * @return array{x: ParagonIE_Sodium_Core_Curve25519_Fe, nonsquare: int} * * @throws SodiumException */
# fe_1(x);         # fe_add(x, x, A.Y);         # fe_mul(x, x, one_minus_y);         $x = self::fe_mul(
            self::fe_add(self::fe_1()$A->Y),
            $one_minux_y
        );

        # fe_tobytes(curve25519_pk, x);         return self::fe_tobytes($x);
    }

    /** * @internal You should not use this directly from another application * * @param string $sk * @return string * @throws SodiumException * @throws TypeError */
    public static function sk_to_pk($sk)
    {

    public static function fe_isnegative(ParagonIE_Sodium_Core32_Curve25519_Fe $f)
    {
        $str = self::fe_tobytes($f);
        return (int) (self::chrToInt($str[0]) & 1);
    }

    /** * Returns 0 if this field element results in all NUL bytes. * * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f * @return bool * @throws SodiumException * @throws TypeError */
Home | Imprint | This part of the site doesn't use cookies.