Summery Summery
Square a field element
Syntax Syntax
Description Description
h = f * f
Parameters Parameters
- $f
-
(Required)
Return Return
Source Source
File: wp-includes/sodium_compat/src/Core/Curve25519.php
public static function fe_sq(ParagonIE_Sodium_Core_Curve25519_Fe $f) { $f0 = (int) $f[0]; $f1 = (int) $f[1]; $f2 = (int) $f[2]; $f3 = (int) $f[3]; $f4 = (int) $f[4]; $f5 = (int) $f[5]; $f6 = (int) $f[6]; $f7 = (int) $f[7]; $f8 = (int) $f[8]; $f9 = (int) $f[9]; /** @var int $f0_2 */ $f0_2 = $f0 << 1; /** @var int $f1_2 */ $f1_2 = $f1 << 1; /** @var int $f2_2 */ $f2_2 = $f2 << 1; /** @var int $f3_2 */ $f3_2 = $f3 << 1; /** @var int $f4_2 */ $f4_2 = $f4 << 1; /** @var int $f5_2 */ $f5_2 = $f5 << 1; /** @var int $f6_2 */ $f6_2 = $f6 << 1; /** @var int $f7_2 */ $f7_2 = $f7 << 1; $f5_38 = self::mul($f5, 38, 6); $f6_19 = self::mul($f6, 19, 5); $f7_38 = self::mul($f7, 38, 6); $f8_19 = self::mul($f8, 19, 5); $f9_38 = self::mul($f9, 38, 6); $f0f0 = self::mul($f0, $f0, 25); $f0f1_2 = self::mul($f0_2, $f1, 24); $f0f2_2 = self::mul($f0_2, $f2, 25); $f0f3_2 = self::mul($f0_2, $f3, 24); $f0f4_2 = self::mul($f0_2, $f4, 25); $f0f5_2 = self::mul($f0_2, $f5, 25); $f0f6_2 = self::mul($f0_2, $f6, 25); $f0f7_2 = self::mul($f0_2, $f7, 24); $f0f8_2 = self::mul($f0_2, $f8, 25); $f0f9_2 = self::mul($f0_2, $f9, 25); $f1f1_2 = self::mul($f1_2, $f1, 24); $f1f2_2 = self::mul($f1_2, $f2, 25); $f1f3_4 = self::mul($f1_2, $f3_2, 25); $f1f4_2 = self::mul($f1_2, $f4, 25); $f1f5_4 = self::mul($f1_2, $f5_2, 26); $f1f6_2 = self::mul($f1_2, $f6, 25); $f1f7_4 = self::mul($f1_2, $f7_2, 25); $f1f8_2 = self::mul($f1_2, $f8, 25); $f1f9_76 = self::mul($f9_38, $f1_2, 25); $f2f2 = self::mul($f2, $f2, 25); $f2f3_2 = self::mul($f2_2, $f3, 24); $f2f4_2 = self::mul($f2_2, $f4, 25); $f2f5_2 = self::mul($f2_2, $f5, 25); $f2f6_2 = self::mul($f2_2, $f6, 25); $f2f7_2 = self::mul($f2_2, $f7, 24); $f2f8_38 = self::mul($f8_19, $f2_2, 26); $f2f9_38 = self::mul($f9_38, $f2, 25); $f3f3_2 = self::mul($f3_2, $f3, 24); $f3f4_2 = self::mul($f3_2, $f4, 25); $f3f5_4 = self::mul($f3_2, $f5_2, 26); $f3f6_2 = self::mul($f3_2, $f6, 25); $f3f7_76 = self::mul($f7_38, $f3_2, 25); $f3f8_38 = self::mul($f8_19, $f3_2, 25); $f3f9_76 = self::mul($f9_38, $f3_2, 25); $f4f4 = self::mul($f4, $f4, 25); $f4f5_2 = self::mul($f4_2, $f5, 25); $f4f6_38 = self::mul($f6_19, $f4_2, 26); $f4f7_38 = self::mul($f7_38, $f4, 25); $f4f8_38 = self::mul($f8_19, $f4_2, 26); $f4f9_38 = self::mul($f9_38, $f4, 25); $f5f5_38 = self::mul($f5_38, $f5, 25); $f5f6_38 = self::mul($f6_19, $f5_2, 26); $f5f7_76 = self::mul($f7_38, $f5_2, 26); $f5f8_38 = self::mul($f8_19, $f5_2, 26); $f5f9_76 = self::mul($f9_38, $f5_2, 26); $f6f6_19 = self::mul($f6_19, $f6, 25); $f6f7_38 = self::mul($f7_38, $f6, 25); $f6f8_38 = self::mul($f8_19, $f6_2, 26); $f6f9_38 = self::mul($f9_38, $f6, 25); $f7f7_38 = self::mul($f7_38, $f7, 24); $f7f8_38 = self::mul($f8_19, $f7_2, 25); $f7f9_76 = self::mul($f9_38, $f7_2, 25); $f8f8_19 = self::mul($f8_19, $f8, 25); $f8f9_38 = self::mul($f9_38, $f8, 25); $f9f9_38 = self::mul($f9_38, $f9, 25); $h0 = $f0f0 + $f1f9_76 + $f2f8_38 + $f3f7_76 + $f4f6_38 + $f5f5_38; $h1 = $f0f1_2 + $f2f9_38 + $f3f8_38 + $f4f7_38 + $f5f6_38; $h2 = $f0f2_2 + $f1f1_2 + $f3f9_76 + $f4f8_38 + $f5f7_76 + $f6f6_19; $h3 = $f0f3_2 + $f1f2_2 + $f4f9_38 + $f5f8_38 + $f6f7_38; $h4 = $f0f4_2 + $f1f3_4 + $f2f2 + $f5f9_76 + $f6f8_38 + $f7f7_38; $h5 = $f0f5_2 + $f1f4_2 + $f2f3_2 + $f6f9_38 + $f7f8_38; $h6 = $f0f6_2 + $f1f5_4 + $f2f4_2 + $f3f3_2 + $f7f9_76 + $f8f8_19; $h7 = $f0f7_2 + $f1f6_2 + $f2f5_2 + $f3f4_2 + $f8f9_38; $h8 = $f0f8_2 + $f1f7_4 + $f2f6_2 + $f3f5_4 + $f4f4 + $f9f9_38; $h9 = $f0f9_2 + $f1f8_2 + $f2f7_2 + $f3f6_2 + $f4f5_2; /** @var int $carry0 */ $carry0 = ($h0 + (1 << 25)) >> 26; $h1 += $carry0; $h0 -= $carry0 << 26; /** @var int $carry4 */ $carry4 = ($h4 + (1 << 25)) >> 26; $h5 += $carry4; $h4 -= $carry4 << 26; /** @var int $carry1 */ $carry1 = ($h1 + (1 << 24)) >> 25; $h2 += $carry1; $h1 -= $carry1 << 25; /** @var int $carry5 */ $carry5 = ($h5 + (1 << 24)) >> 25; $h6 += $carry5; $h5 -= $carry5 << 25; /** @var int $carry2 */ $carry2 = ($h2 + (1 << 25)) >> 26; $h3 += $carry2; $h2 -= $carry2 << 26; /** @var int $carry6 */ $carry6 = ($h6 + (1 << 25)) >> 26; $h7 += $carry6; $h6 -= $carry6 << 26; /** @var int $carry3 */ $carry3 = ($h3 + (1 << 24)) >> 25; $h4 += $carry3; $h3 -= $carry3 << 25; /** @var int $carry7 */ $carry7 = ($h7 + (1 << 24)) >> 25; $h8 += $carry7; $h7 -= $carry7 << 25; /** @var int $carry4 */ $carry4 = ($h4 + (1 << 25)) >> 26; $h5 += $carry4; $h4 -= $carry4 << 26; /** @var int $carry8 */ $carry8 = ($h8 + (1 << 25)) >> 26; $h9 += $carry8; $h8 -= $carry8 << 26; /** @var int $carry9 */ $carry9 = ($h9 + (1 << 24)) >> 25; $h0 += self::mul($carry9, 19, 5); $h9 -= $carry9 << 25; /** @var int $carry0 */ $carry0 = ($h0 + (1 << 25)) >> 26; $h1 += $carry0; $h0 -= $carry0 << 26; return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray( array( (int) $h0, (int) $h1, (int) $h2, (int) $h3, (int) $h4, (int) $h5, (int) $h6, (int) $h7, (int) $h8, (int) $h9 ) ); }