ParagonIE_Sodium_Crypto::scalarmult_throw_if_zero

Advertisement

Summery Summery

This throws an Error if a zero public key was passed to the function.

Syntax Syntax

ParagonIE_Sodium_Crypto::scalarmult_throw_if_zero( string $q )

Parameters Parameters

$q

(string) (Required)

Return Return

(void)

Source Source

File: wp-includes/sodium_compat/src/Crypto.php

    protected static function scalarmult_throw_if_zero($q)
    {
        $d = 0;
        for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) {
            $d |= ParagonIE_Sodium_Core_Util::chrToInt($q[$i]);
        }

        /* branch-free variant of === 0 */
        if (-(1 & (($d - 1) >> 8))) {
            throw new SodiumException('Zero public key is not allowed');
        }
    }

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.