wppaste
WordPress

ParagonIE_Sodium_Core_Curve25519::sc25519_mul( string $a, string $b ): string

Source
wp-includes/sodium_compat/src/Core/Curve25519.php:2913

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$astring
$bstring

Return value

string

Performance profile

How much work a call to ParagonIE_Sodium_Core_Curve25519::sc25519_mul() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
2034

Executed per call on PHP 8.5. The body compiles to 2034.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
3

3 places in core call this, so the cost is paid more often than your own code shows.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost ParagonIE_Sodium_Core_Curve25519::sc25519_mul() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always2034::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::substr(), ::load_3(), ::substr(), ::load_4(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), ::mul(), array_fill(), ::intArrayToString()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 2034 instructions, 2034 executed per call, 0 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 5

  • ParagonIE_Sodium_Core_Curve25519::load_3()
  • ParagonIE_Sodium_Core_Curve25519::substr()
  • ParagonIE_Sodium_Core_Curve25519::load_4()
  • ParagonIE_Sodium_Core_Curve25519::mul()
  • ParagonIE_Sodium_Core_Curve25519::intArrayToString()

Used by · 3

Source code

    public static function sc25519_mul($a, $b)    {        //    int64_t a0  = 2097151 & load_3(a);        //    int64_t a1  = 2097151 & (load_4(a + 2) >> 5);        //    int64_t a2  = 2097151 & (load_3(a + 5) >> 2);        //    int64_t a3  = 2097151 & (load_4(a + 7) >> 7);        //    int64_t a4  = 2097151 & (load_4(a + 10) >> 4);        //    int64_t a5  = 2097151 & (load_3(a + 13) >> 1);        //    int64_t a6  = 2097151 & (load_4(a + 15) >> 6);        //    int64_t a7  = 2097151 & (load_3(a + 18) >> 3);        //    int64_t a8  = 2097151 & load_3(a + 21);        //    int64_t a9  = 2097151 & (load_4(a + 23) >> 5);        //    int64_t a10 = 2097151 & (load_3(a + 26) >> 2);        //    int64_t a11 = (load_4(a + 28) >> 7);        $a0  = 2097151 &  self::load_3(self::substr($a, 0, 3));        $a1  = 2097151 & (self::load_4(self::substr($a, 2, 4)) >> 5);        $a2  = 2097151 & (self::load_3(self::substr($a, 5, 3)) >> 2);        $a3  = 2097151 & (self::load_4(self::substr($a, 7, 4)) >> 7);        $a4  = 2097151 & (self::load_4(self::substr($a, 10, 4)) >> 4);        $a5  = 2097151 & (self::load_3(self::substr($a, 13, 3)) >> 1);        $a6  = 2097151 & (self::load_4(self::substr($a, 15, 4)) >> 6);        $a7  = 2097151 & (self::load_3(self::substr($a, 18, 3)) >> 3);        $a8  = 2097151 &  self::load_3(self::substr($a, 21, 3));        $a9  = 2097151 & (self::load_4(self::substr($a, 23, 4)) >> 5);        $a10 = 2097151 & (self::load_3(self::substr($a, 26, 3)) >> 2);        $a11 = (self::load_4(self::substr($a, 28, 4)) >> 7);         //    int64_t b0  = 2097151 & load_3(b);        //    int64_t b1  = 2097151 & (load_4(b + 2) >> 5);        //    int64_t b2  = 2097151 & (load_3(b + 5) >> 2);        //    int64_t b3  = 2097151 & (load_4(b + 7) >> 7);        //    int64_t b4  = 2097151 & (load_4(b + 10) >> 4);        //    int64_t b5  = 2097151 & (load_3(b + 13) >> 1);        //    int64_t b6  = 2097151 & (load_4(b + 15) >> 6);        //    int64_t b7  = 2097151 & (load_3(b + 18) >> 3);        //    int64_t b8  = 2097151 & load_3(b + 21);        //    int64_t b9  = 2097151 & (load_4(b + 23) >> 5);        //    int64_t b10 = 2097151 & (load_3(b + 26) >> 2);        //    int64_t b11 = (load_4(b + 28) >> 7);        $b0  = 2097151 &  self::load_3(self::substr($b, 0, 3));        $b1  = 2097151 & (self::load_4(self::substr($b, 2, 4)) >> 5);        $b2  = 2097151 & (self::load_3(self::substr($b, 5, 3)) >> 2);        $b3  = 2097151 & (self::load_4(self::substr($b, 7, 4)) >> 7);        $b4  = 2097151 & (self::load_4(self::substr($b, 10, 4)) >> 4);        $b5  = 2097151 & (self::load_3(self::substr($b, 13, 3)) >> 1);        $b6  = 2097151 & (self::load_4(self::substr($b, 15, 4)) >> 6);        $b7  = 2097151 & (self::load_3(self::substr($b, 18, 3)) >> 3);        $b8  = 2097151 &  self::load_3(self::substr($b, 21, 3));        $b9  = 2097151 & (self::load_4(self::substr($b, 23, 4)) >> 5);        $b10 = 2097151 & (self::load_3(self::substr($b, 26, 3)) >> 2);        $b11 = (self::load_4(self::substr($b, 28, 4)) >> 7);         //    s0 = a0 * b0;        //    s1 = a0 * b1 + a1 * b0;        //    s2 = a0 * b2 + a1 * b1 + a2 * b0;        //    s3 = a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0;        //    s4 = a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0;        //    s5 = a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0;        //    s6 = a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0;        //    s7 = a0 * b7 + a1 * b6 + a2 * b5 + a3 * b4 + a4 * b3 + a5 * b2 +        //        a6 * b1 + a7 * b0;        //    s8 = a0 * b8 + a1 * b7 + a2 * b6 + a3 * b5 + a4 * b4 + a5 * b3 +        //        a6 * b2 + a7 * b1 + a8 * b0;        //    s9 = a0 * b9 + a1 * b8 + a2 * b7 + a3 * b6 + a4 * b5 + a5 * b4 +        //        a6 * b3 + a7 * b2 + a8 * b1 + a9 * b0;        //    s10 = a0 * b10 + a1 * b9 + a2 * b8 + a3 * b7 + a4 * b6 + a5 * b5 +        //        a6 * b4 + a7 * b3 + a8 * b2 + a9 * b1 + a10 * b0;        //    s11 = a0 * b11 + a1 * b10 + a2 * b9 + a3 * b8 + a4 * b7 + a5 * b6 +        //        a6 * b5 + a7 * b4 + a8 * b3 + a9 * b2 + a10 * b1 + a11 * b0;        //    s12 = a1 * b11 + a2 * b10 + a3 * b9 + a4 * b8 + a5 * b7 + a6 * b6 +        //        a7 * b5 + a8 * b4 + a9 * b3 + a10 * b2 + a11 * b1;        //    s13 = a2 * b11 + a3 * b10 + a4 * b9 + a5 * b8 + a6 * b7 + a7 * b6 +        //        a8 * b5 + a9 * b4 + a10 * b3 + a11 * b2;        //    s14 = a3 * b11 + a4 * b10 + a5 * b9 + a6 * b8 + a7 * b7 + a8 * b6 +        //        a9 * b5 + a10 * b4 + a11 * b3;        //    s15 = a4 * b11 + a5 * b10 + a6 * b9 + a7 * b8 + a8 * b7 + a9 * b6 +        //        a10 * b5 + a11 * b4;        //    s16 =        //        a5 * b11 + a6 * b10 + a7 * b9 + a8 * b8 + a9 * b7 + a10 * b6 + a11 * b5;        //    s17 = a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6;

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/sodium_compat/src/Core/Curve25519.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.