ParagonIE_Sodium_Core32_Int32::multiplyLong() –

You appear to be a bot. Output may be restricted

Description

Usage

$array

Parameters

$a
( mixed ) required -
$b
( mixed ) required -
$baseLog2
( int ) optional default: 16 -

Returns

array int>

Source

File name: wordpress/wp-includes/sodium_compat/src/Core32/Int32.php


Lines:

1 to 21 of 21
    public function multiplyLong(array $a, array $b, $baseLog2 = 16)
    {
        $a_l = count($a);
        $b_l = count($b);
        
/** @var array<int, int> $r */
        $r = array_fill(0, $a_l + $b_l + 1, 0);
        $base = 1 << $baseLog2;
        for ($i = 0; $i < $a_l; ++$i) {
            $a_i = $a[$i];
            for ($j = 0; $j < $a_l; ++$j) {
                $b_j = $b[$j];
                $product = ($a_i * $b_j) + $r[$i + $j];
                $carry = ((int) $product >> $baseLog2 & 0xffff);
                $r[$i + $j] = ((int) $product - (int) ($carry * $base)) & 0xffff;
                $r[$i + $j + 1] += $carry;
            }
        }
        return array_slice($r, 0, 5);
    }
 

 View on GitHub View on Trac