ParagonIE_Sodium_Core32_X25519::crypto_scalarmult_curve25519_ref10_base

Advertisement

Syntax Syntax

ParagonIE_Sodium_Core32_X25519::crypto_scalarmult_curve25519_ref10_base( string $n )

Parameters Parameters

$n

(Required)

Return Return

(string)

Source Source

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

    public static function crypto_scalarmult_curve25519_ref10_base($n)
    {
        # for (i = 0;i < 32;++i) e[i] = n[i];
        $e = '' . $n;

        # e[0] &= 248;
        $e[0] = self::intToChr(
            self::chrToInt($e[0]) & 248
        );

        # e[31] &= 127;
        # e[31] |= 64;
        $e[31] = self::intToChr(
            (self::chrToInt($e[31]) & 127) | 64
        );

        $A = self::ge_scalarmult_base($e);
        if (
            !($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
                ||
            !($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
        ) {
            throw new TypeError('Null points encountered');
        }
        $pk = self::edwards_to_montgomery($A->Y, $A->Z);
        return self::fe_tobytes($pk);
    }

Advertisement

Advertisement

Leave a Reply