ParagonIE_Sodium_Core32_Curve25519::fe_cmov

Advertisement

Summery Summery

Constant-time conditional move.

Syntax Syntax

ParagonIE_Sodium_Core32_Curve25519::fe_cmov( ParagonIE_Sodium_Core32_Curve25519_Fe $f, ParagonIE_Sodium_Core32_Curve25519_Fe $g, int $b )

Parameters Parameters

$f

(Required)

$g

(Required)

$b

(Required)

Return Return

(ParagonIE_Sodium_Core32_Curve25519_Fe)

Source Source

File: wp-includes/sodium_compat/src/Core32/Curve25519.php

    public static function fe_cmov(
        ParagonIE_Sodium_Core32_Curve25519_Fe $f,
        ParagonIE_Sodium_Core32_Curve25519_Fe $g,
        $b = 0
    ) {
        /** @var array<int, ParagonIE_Sodium_Core32_Int32> $h */
        $h = array();
        for ($i = 0; $i < 10; ++$i) {
            if (!($f[$i] instanceof ParagonIE_Sodium_Core32_Int32)) {
                throw new TypeError('Expected Int32');
            }
            if (!($g[$i] instanceof ParagonIE_Sodium_Core32_Int32)) {
                throw new TypeError('Expected Int32');
            }
            $h[$i] = $f[$i]->xorInt32(
                $f[$i]->xorInt32($g[$i])->mask($b)
            );
        }
        /** @var array<int, ParagonIE_Sodium_Core32_Int32> $h */
        return ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray($h);
    }

Advertisement

Advertisement

Leave a Reply