Summery Summery
Convert a field element to a byte string.
Syntax Syntax
Parameters Parameters
- $h
-
(Required)
Return Return
(string)
Source Source
File: wp-includes/sodium_compat/src/Core/Curve25519.php
public static function fe_tobytes(ParagonIE_Sodium_Core_Curve25519_Fe $h) { /** @var int $h0 */ $h0 = (int) $h[0]; /** @var int $h1 */ $h1 = (int) $h[1]; /** @var int $h2 */ $h2 = (int) $h[2]; /** @var int $h3 */ $h3 = (int) $h[3]; /** @var int $h4 */ $h4 = (int) $h[4]; /** @var int $h5 */ $h5 = (int) $h[5]; /** @var int $h6 */ $h6 = (int) $h[6]; /** @var int $h7 */ $h7 = (int) $h[7]; /** @var int $h8 */ $h8 = (int) $h[8]; /** @var int $h9 */ $h9 = (int) $h[9]; /** @var int $q */ $q = (self::mul($h9, 19, 5) + (1 << 24)) >> 25; /** @var int $q */ $q = ($h0 + $q) >> 26; /** @var int $q */ $q = ($h1 + $q) >> 25; /** @var int $q */ $q = ($h2 + $q) >> 26; /** @var int $q */ $q = ($h3 + $q) >> 25; /** @var int $q */ $q = ($h4 + $q) >> 26; /** @var int $q */ $q = ($h5 + $q) >> 25; /** @var int $q */ $q = ($h6 + $q) >> 26; /** @var int $q */ $q = ($h7 + $q) >> 25; /** @var int $q */ $q = ($h8 + $q) >> 26; /** @var int $q */ $q = ($h9 + $q) >> 25; $h0 += self::mul($q, 19, 5); /** @var int $carry0 */ $carry0 = $h0 >> 26; $h1 += $carry0; $h0 -= $carry0 << 26; /** @var int $carry1 */ $carry1 = $h1 >> 25; $h2 += $carry1; $h1 -= $carry1 << 25; /** @var int $carry2 */ $carry2 = $h2 >> 26; $h3 += $carry2; $h2 -= $carry2 << 26; /** @var int $carry3 */ $carry3 = $h3 >> 25; $h4 += $carry3; $h3 -= $carry3 << 25; /** @var int $carry4 */ $carry4 = $h4 >> 26; $h5 += $carry4; $h4 -= $carry4 << 26; /** @var int $carry5 */ $carry5 = $h5 >> 25; $h6 += $carry5; $h5 -= $carry5 << 25; /** @var int $carry6 */ $carry6 = $h6 >> 26; $h7 += $carry6; $h6 -= $carry6 << 26; /** @var int $carry7 */ $carry7 = $h7 >> 25; $h8 += $carry7; $h7 -= $carry7 << 25; /** @var int $carry8 */ $carry8 = $h8 >> 26; $h9 += $carry8; $h8 -= $carry8 << 26; /** @var int $carry9 */ $carry9 = $h9 >> 25; $h9 -= $carry9 << 25; /** * @var array<int, int> */ $s = array( (int) (($h0 >> 0) & 0xff), (int) (($h0 >> 8) & 0xff), (int) (($h0 >> 16) & 0xff), (int) ((($h0 >> 24) | ($h1 << 2)) & 0xff), (int) (($h1 >> 6) & 0xff), (int) (($h1 >> 14) & 0xff), (int) ((($h1 >> 22) | ($h2 << 3)) & 0xff), (int) (($h2 >> 5) & 0xff), (int) (($h2 >> 13) & 0xff), (int) ((($h2 >> 21) | ($h3 << 5)) & 0xff), (int) (($h3 >> 3) & 0xff), (int) (($h3 >> 11) & 0xff), (int) ((($h3 >> 19) | ($h4 << 6)) & 0xff), (int) (($h4 >> 2) & 0xff), (int) (($h4 >> 10) & 0xff), (int) (($h4 >> 18) & 0xff), (int) (($h5 >> 0) & 0xff), (int) (($h5 >> 8) & 0xff), (int) (($h5 >> 16) & 0xff), (int) ((($h5 >> 24) | ($h6 << 1)) & 0xff), (int) (($h6 >> 7) & 0xff), (int) (($h6 >> 15) & 0xff), (int) ((($h6 >> 23) | ($h7 << 3)) & 0xff), (int) (($h7 >> 5) & 0xff), (int) (($h7 >> 13) & 0xff), (int) ((($h7 >> 21) | ($h8 << 4)) & 0xff), (int) (($h8 >> 4) & 0xff), (int) (($h8 >> 12) & 0xff), (int) ((($h8 >> 20) | ($h9 << 6)) & 0xff), (int) (($h9 >> 2) & 0xff), (int) (($h9 >> 10) & 0xff), (int) (($h9 >> 18) & 0xff) ); return self::intArrayToString($s); }