@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Salsa20 |
9 | 9 | */ |
10 | -abstract class ParagonIE_Sodium_Core_Salsa20 extends ParagonIE_Sodium_Core_Util |
|
11 | -{ |
|
10 | +abstract class ParagonIE_Sodium_Core_Salsa20 extends ParagonIE_Sodium_Core_Util { |
|
12 | 11 | const ROUNDS = 20; |
13 | 12 | |
14 | 13 | /** |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | * @return string |
23 | 22 | * @throws TypeError |
24 | 23 | */ |
25 | - public static function core_salsa20($in, $k, $c = null) |
|
26 | - { |
|
24 | + public static function core_salsa20($in, $k, $c = null) { |
|
27 | 25 | if (self::strlen($k) < 32) { |
28 | 26 | throw new RangeException('Key must be 32 bytes long'); |
29 | 27 | } |
@@ -138,8 +136,7 @@ discard block |
||
138 | 136 | * @throws SodiumException |
139 | 137 | * @throws TypeError |
140 | 138 | */ |
141 | - public static function salsa20($len, $nonce, $key) |
|
142 | - { |
|
139 | + public static function salsa20($len, $nonce, $key) { |
|
143 | 140 | if (self::strlen($key) !== 32) { |
144 | 141 | throw new RangeException('Key must be 32 bytes long'); |
145 | 142 | } |
@@ -183,8 +180,7 @@ discard block |
||
183 | 180 | * @throws SodiumException |
184 | 181 | * @throws TypeError |
185 | 182 | */ |
186 | - public static function salsa20_xor_ic($m, $n, $ic, $k) |
|
187 | - { |
|
183 | + public static function salsa20_xor_ic($m, $n, $ic, $k) { |
|
188 | 184 | $mlen = self::strlen($m); |
189 | 185 | if ($mlen < 1) { |
190 | 186 | return ''; |
@@ -240,8 +236,7 @@ discard block |
||
240 | 236 | * @throws SodiumException |
241 | 237 | * @throws TypeError |
242 | 238 | */ |
243 | - public static function salsa20_xor($message, $nonce, $key) |
|
244 | - { |
|
239 | + public static function salsa20_xor($message, $nonce, $key) { |
|
245 | 240 | return self::xorStrings( |
246 | 241 | $message, |
247 | 242 | self::salsa20( |
@@ -259,8 +254,7 @@ discard block |
||
259 | 254 | * @param int $c |
260 | 255 | * @return int |
261 | 256 | */ |
262 | - public static function rotate($u, $c) |
|
263 | - { |
|
257 | + public static function rotate($u, $c) { |
|
264 | 258 | $u &= 0xffffffff; |
265 | 259 | $c %= 32; |
266 | 260 | return (int) (0xffffffff & ( |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * This represents a Field Element |
11 | 11 | */ |
12 | -class ParagonIE_Sodium_Core_Curve25519_Fe implements ArrayAccess |
|
13 | -{ |
|
12 | +class ParagonIE_Sodium_Core_Curve25519_Fe implements ArrayAccess { |
|
14 | 13 | /** |
15 | 14 | * @var array<int, int> |
16 | 15 | */ |
@@ -28,8 +27,7 @@ discard block |
||
28 | 27 | * @param bool $save_indexes |
29 | 28 | * @return self |
30 | 29 | */ |
31 | - public static function fromArray($array, $save_indexes = null) |
|
32 | - { |
|
30 | + public static function fromArray($array, $save_indexes = null) { |
|
33 | 31 | $count = count($array); |
34 | 32 | if ($save_indexes) { |
35 | 33 | $keys = array_keys($array); |
@@ -61,8 +59,7 @@ discard block |
||
61 | 59 | * @psalm-suppress MixedArrayOffset |
62 | 60 | */ |
63 | 61 | #[ReturnTypeWillChange] |
64 | - public function offsetSet($offset, $value) |
|
65 | - { |
|
62 | + public function offsetSet($offset, $value) { |
|
66 | 63 | if (!is_int($value)) { |
67 | 64 | throw new InvalidArgumentException('Expected an integer'); |
68 | 65 | } |
@@ -81,8 +78,7 @@ discard block |
||
81 | 78 | * @psalm-suppress MixedArrayOffset |
82 | 79 | */ |
83 | 80 | #[ReturnTypeWillChange] |
84 | - public function offsetExists($offset) |
|
85 | - { |
|
81 | + public function offsetExists($offset) { |
|
86 | 82 | return isset($this->container[$offset]); |
87 | 83 | } |
88 | 84 | |
@@ -94,8 +90,7 @@ discard block |
||
94 | 90 | * @psalm-suppress MixedArrayOffset |
95 | 91 | */ |
96 | 92 | #[ReturnTypeWillChange] |
97 | - public function offsetUnset($offset) |
|
98 | - { |
|
93 | + public function offsetUnset($offset) { |
|
99 | 94 | unset($this->container[$offset]); |
100 | 95 | } |
101 | 96 | |
@@ -107,8 +102,7 @@ discard block |
||
107 | 102 | * @psalm-suppress MixedArrayOffset |
108 | 103 | */ |
109 | 104 | #[ReturnTypeWillChange] |
110 | - public function offsetGet($offset) |
|
111 | - { |
|
105 | + public function offsetGet($offset) { |
|
112 | 106 | if (!isset($this->container[$offset])) { |
113 | 107 | $this->container[$offset] = 0; |
114 | 108 | } |
@@ -120,8 +114,7 @@ discard block |
||
120 | 114 | * |
121 | 115 | * @return array |
122 | 116 | */ |
123 | - public function __debugInfo() |
|
124 | - { |
|
117 | + public function __debugInfo() { |
|
125 | 118 | return array(implode(', ', $this->container)); |
126 | 119 | } |
127 | 120 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * This just contains the constants in the ref10/base.h file |
11 | 11 | */ |
12 | -class ParagonIE_Sodium_Core_Curve25519_H extends ParagonIE_Sodium_Core_Util |
|
13 | -{ |
|
12 | +class ParagonIE_Sodium_Core_Curve25519_H extends ParagonIE_Sodium_Core_Util { |
|
14 | 13 | /** |
15 | 14 | * See: libsodium's crypto_core/curve25519/ref10/base.h |
16 | 15 | * |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Curve25519_Ge_P3 |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core_Curve25519_Ge_P3 |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core_Curve25519_Ge_P3 { |
|
12 | 11 | /** |
13 | 12 | * @var ParagonIE_Sodium_Core_Curve25519_Fe |
14 | 13 | */ |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Curve25519_Ge_P2 |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core_Curve25519_Ge_P2 |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core_Curve25519_Ge_P2 { |
|
12 | 11 | /** |
13 | 12 | * @var ParagonIE_Sodium_Core_Curve25519_Fe |
14 | 13 | */ |
@@ -6,8 +6,7 @@ |
||
6 | 6 | /** |
7 | 7 | * Class ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 |
8 | 8 | */ |
9 | -class ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 |
|
10 | -{ |
|
9 | +class ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 { |
|
11 | 10 | /** |
12 | 11 | * @var ParagonIE_Sodium_Core_Curve25519_Fe |
13 | 12 | */ |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Curve25519_Ge_Cached |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core_Curve25519_Ge_Cached |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core_Curve25519_Ge_Cached { |
|
12 | 11 | /** |
13 | 12 | * @var ParagonIE_Sodium_Core_Curve25519_Fe |
14 | 13 | */ |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * Class ParagonIE_Sodium_Core_Curve25519_Ge_Precomp |
9 | 9 | */ |
10 | -class ParagonIE_Sodium_Core_Curve25519_Ge_Precomp |
|
11 | -{ |
|
10 | +class ParagonIE_Sodium_Core_Curve25519_Ge_Precomp { |
|
12 | 11 | /** |
13 | 12 | * @var ParagonIE_Sodium_Core_Curve25519_Fe |
14 | 13 | */ |
@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @ref https://github.com/jedisct1/libsodium/blob/master/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c |
15 | 15 | */ |
16 | -abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Curve25519_H |
|
17 | -{ |
|
16 | +abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Curve25519_H { |
|
18 | 17 | /** |
19 | 18 | * Get a field element of size 10 with a value of 0 |
20 | 19 | * |
@@ -22,8 +21,7 @@ discard block |
||
22 | 21 | * |
23 | 22 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
24 | 23 | */ |
25 | - public static function fe_0() |
|
26 | - { |
|
24 | + public static function fe_0() { |
|
27 | 25 | return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray( |
28 | 26 | array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0) |
29 | 27 | ); |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | * |
37 | 35 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
38 | 36 | */ |
39 | - public static function fe_1() |
|
40 | - { |
|
37 | + public static function fe_1() { |
|
41 | 38 | return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray( |
42 | 39 | array(1, 0, 0, 0, 0, 0, 0, 0, 0, 0) |
43 | 40 | ); |
@@ -100,8 +97,7 @@ discard block |
||
100 | 97 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $f |
101 | 98 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
102 | 99 | */ |
103 | - public static function fe_copy(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
104 | - { |
|
100 | + public static function fe_copy(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
105 | 101 | $h = clone $f; |
106 | 102 | return $h; |
107 | 103 | } |
@@ -117,8 +113,7 @@ discard block |
||
117 | 113 | * @throws RangeException |
118 | 114 | * @throws TypeError |
119 | 115 | */ |
120 | - public static function fe_frombytes($s) |
|
121 | - { |
|
116 | + public static function fe_frombytes($s) { |
|
122 | 117 | if (self::strlen($s) !== 32) { |
123 | 118 | throw new RangeException('Expected a 32-byte string.'); |
124 | 119 | } |
@@ -189,8 +184,7 @@ discard block |
||
189 | 184 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $h |
190 | 185 | * @return string |
191 | 186 | */ |
192 | - public static function fe_tobytes(ParagonIE_Sodium_Core_Curve25519_Fe $h) |
|
193 | - { |
|
187 | + public static function fe_tobytes(ParagonIE_Sodium_Core_Curve25519_Fe $h) { |
|
194 | 188 | $h0 = (int) $h[0]; |
195 | 189 | $h1 = (int) $h[1]; |
196 | 190 | $h2 = (int) $h[2]; |
@@ -296,8 +290,7 @@ discard block |
||
296 | 290 | * @throws SodiumException |
297 | 291 | * @throws TypeError |
298 | 292 | */ |
299 | - public static function fe_isnegative(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
300 | - { |
|
293 | + public static function fe_isnegative(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
301 | 294 | $str = self::fe_tobytes($f); |
302 | 295 | return (int) (self::chrToInt($str[0]) & 1); |
303 | 296 | } |
@@ -312,8 +305,7 @@ discard block |
||
312 | 305 | * @throws SodiumException |
313 | 306 | * @throws TypeError |
314 | 307 | */ |
315 | - public static function fe_isnonzero(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
316 | - { |
|
308 | + public static function fe_isnonzero(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
317 | 309 | static $zero; |
318 | 310 | if ($zero === null) { |
319 | 311 | $zero = str_repeat("\x00", 32); |
@@ -557,8 +549,7 @@ discard block |
||
557 | 549 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
558 | 550 | * @psalm-suppress MixedAssignment |
559 | 551 | */ |
560 | - public static function fe_neg(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
561 | - { |
|
552 | + public static function fe_neg(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
562 | 553 | $h = new ParagonIE_Sodium_Core_Curve25519_Fe(); |
563 | 554 | for ($i = 0; $i < 10; ++$i) { |
564 | 555 | $h[$i] = -$f[$i]; |
@@ -576,8 +567,7 @@ discard block |
||
576 | 567 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $f |
577 | 568 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
578 | 569 | */ |
579 | - public static function fe_sq(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
580 | - { |
|
570 | + public static function fe_sq(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
581 | 571 | $f0 = (int) $f[0]; |
582 | 572 | $f1 = (int) $f[1]; |
583 | 573 | $f2 = (int) $f[2]; |
@@ -738,8 +728,7 @@ discard block |
||
738 | 728 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $f |
739 | 729 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
740 | 730 | */ |
741 | - public static function fe_sq2(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
742 | - { |
|
731 | + public static function fe_sq2(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
743 | 732 | $f0 = (int) $f[0]; |
744 | 733 | $f1 = (int) $f[1]; |
745 | 734 | $f2 = (int) $f[2]; |
@@ -896,8 +885,7 @@ discard block |
||
896 | 885 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $Z |
897 | 886 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
898 | 887 | */ |
899 | - public static function fe_invert(ParagonIE_Sodium_Core_Curve25519_Fe $Z) |
|
900 | - { |
|
888 | + public static function fe_invert(ParagonIE_Sodium_Core_Curve25519_Fe $Z) { |
|
901 | 889 | $z = clone $Z; |
902 | 890 | $t0 = self::fe_sq($z); |
903 | 891 | $t1 = self::fe_sq($t0); |
@@ -956,8 +944,7 @@ discard block |
||
956 | 944 | * @param ParagonIE_Sodium_Core_Curve25519_Fe $z |
957 | 945 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
958 | 946 | */ |
959 | - public static function fe_pow22523(ParagonIE_Sodium_Core_Curve25519_Fe $z) |
|
960 | - { |
|
947 | + public static function fe_pow22523(ParagonIE_Sodium_Core_Curve25519_Fe $z) { |
|
961 | 948 | # fe_sq(t0, z); |
962 | 949 | # fe_sq(t1, t0); |
963 | 950 | # fe_sq(t1, t1); |
@@ -1083,8 +1070,7 @@ discard block |
||
1083 | 1070 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
1084 | 1071 | * @psalm-suppress MixedOperand |
1085 | 1072 | */ |
1086 | - public static function fe_sub(ParagonIE_Sodium_Core_Curve25519_Fe $f, ParagonIE_Sodium_Core_Curve25519_Fe $g) |
|
1087 | - { |
|
1073 | + public static function fe_sub(ParagonIE_Sodium_Core_Curve25519_Fe $f, ParagonIE_Sodium_Core_Curve25519_Fe $g) { |
|
1088 | 1074 | return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray( |
1089 | 1075 | array( |
1090 | 1076 | (int) ($f[0] - $g[0]), |
@@ -1140,8 +1126,7 @@ discard block |
||
1140 | 1126 | * @throws SodiumException |
1141 | 1127 | * @throws TypeError |
1142 | 1128 | */ |
1143 | - public static function slide($a) |
|
1144 | - { |
|
1129 | + public static function slide($a) { |
|
1145 | 1130 | if (self::strlen($a) < 256) { |
1146 | 1131 | if (self::strlen($a) < 16) { |
1147 | 1132 | $a = str_pad($a, 256, '0', STR_PAD_RIGHT); |
@@ -1195,8 +1180,7 @@ discard block |
||
1195 | 1180 | * @throws SodiumException |
1196 | 1181 | * @throws TypeError |
1197 | 1182 | */ |
1198 | - public static function ge_frombytes_negate_vartime($s) |
|
1199 | - { |
|
1183 | + public static function ge_frombytes_negate_vartime($s) { |
|
1200 | 1184 | static $d = null; |
1201 | 1185 | if (!$d) { |
1202 | 1186 | $d = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$d); |
@@ -1339,8 +1323,7 @@ discard block |
||
1339 | 1323 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p |
1340 | 1324 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P2 |
1341 | 1325 | */ |
1342 | - public static function ge_p1p1_to_p2(ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p) |
|
1343 | - { |
|
1326 | + public static function ge_p1p1_to_p2(ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p) { |
|
1344 | 1327 | $r = new ParagonIE_Sodium_Core_Curve25519_Ge_P2(); |
1345 | 1328 | $r->X = self::fe_mul($p->X, $p->T); |
1346 | 1329 | $r->Y = self::fe_mul($p->Y, $p->Z); |
@@ -1354,8 +1337,7 @@ discard block |
||
1354 | 1337 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p |
1355 | 1338 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P3 |
1356 | 1339 | */ |
1357 | - public static function ge_p1p1_to_p3(ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p) |
|
1358 | - { |
|
1340 | + public static function ge_p1p1_to_p3(ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 $p) { |
|
1359 | 1341 | $r = new ParagonIE_Sodium_Core_Curve25519_Ge_P3(); |
1360 | 1342 | $r->X = self::fe_mul($p->X, $p->T); |
1361 | 1343 | $r->Y = self::fe_mul($p->Y, $p->Z); |
@@ -1369,8 +1351,7 @@ discard block |
||
1369 | 1351 | * |
1370 | 1352 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P2 |
1371 | 1353 | */ |
1372 | - public static function ge_p2_0() |
|
1373 | - { |
|
1354 | + public static function ge_p2_0() { |
|
1374 | 1355 | return new ParagonIE_Sodium_Core_Curve25519_Ge_P2( |
1375 | 1356 | self::fe_0(), |
1376 | 1357 | self::fe_1(), |
@@ -1384,8 +1365,7 @@ discard block |
||
1384 | 1365 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P2 $p |
1385 | 1366 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 |
1386 | 1367 | */ |
1387 | - public static function ge_p2_dbl(ParagonIE_Sodium_Core_Curve25519_Ge_P2 $p) |
|
1388 | - { |
|
1368 | + public static function ge_p2_dbl(ParagonIE_Sodium_Core_Curve25519_Ge_P2 $p) { |
|
1389 | 1369 | $r = new ParagonIE_Sodium_Core_Curve25519_Ge_P1p1(); |
1390 | 1370 | |
1391 | 1371 | $r->X = self::fe_sq($p->X); |
@@ -1406,8 +1386,7 @@ discard block |
||
1406 | 1386 | * |
1407 | 1387 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P3 |
1408 | 1388 | */ |
1409 | - public static function ge_p3_0() |
|
1410 | - { |
|
1389 | + public static function ge_p3_0() { |
|
1411 | 1390 | return new ParagonIE_Sodium_Core_Curve25519_Ge_P3( |
1412 | 1391 | self::fe_0(), |
1413 | 1392 | self::fe_1(), |
@@ -1422,8 +1401,7 @@ discard block |
||
1422 | 1401 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p |
1423 | 1402 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_Cached |
1424 | 1403 | */ |
1425 | - public static function ge_p3_to_cached(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) |
|
1426 | - { |
|
1404 | + public static function ge_p3_to_cached(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) { |
|
1427 | 1405 | static $d2 = null; |
1428 | 1406 | if ($d2 === null) { |
1429 | 1407 | $d2 = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$d2); |
@@ -1443,8 +1421,7 @@ discard block |
||
1443 | 1421 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p |
1444 | 1422 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P2 |
1445 | 1423 | */ |
1446 | - public static function ge_p3_to_p2(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) |
|
1447 | - { |
|
1424 | + public static function ge_p3_to_p2(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) { |
|
1448 | 1425 | return new ParagonIE_Sodium_Core_Curve25519_Ge_P2( |
1449 | 1426 | self::fe_copy($p->X), |
1450 | 1427 | self::fe_copy($p->Y), |
@@ -1460,8 +1437,7 @@ discard block |
||
1460 | 1437 | * @throws SodiumException |
1461 | 1438 | * @throws TypeError |
1462 | 1439 | */ |
1463 | - public static function ge_p3_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $h) |
|
1464 | - { |
|
1440 | + public static function ge_p3_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $h) { |
|
1465 | 1441 | $recip = self::fe_invert($h->Z); |
1466 | 1442 | $x = self::fe_mul($h->X, $recip); |
1467 | 1443 | $y = self::fe_mul($h->Y, $recip); |
@@ -1478,8 +1454,7 @@ discard block |
||
1478 | 1454 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p |
1479 | 1455 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P1p1 |
1480 | 1456 | */ |
1481 | - public static function ge_p3_dbl(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) |
|
1482 | - { |
|
1457 | + public static function ge_p3_dbl(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $p) { |
|
1483 | 1458 | $q = self::ge_p3_to_p2($p); |
1484 | 1459 | return self::ge_p2_dbl($q); |
1485 | 1460 | } |
@@ -1487,8 +1462,7 @@ discard block |
||
1487 | 1462 | /** |
1488 | 1463 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_Precomp |
1489 | 1464 | */ |
1490 | - public static function ge_precomp_0() |
|
1491 | - { |
|
1465 | + public static function ge_precomp_0() { |
|
1492 | 1466 | return new ParagonIE_Sodium_Core_Curve25519_Ge_Precomp( |
1493 | 1467 | self::fe_1(), |
1494 | 1468 | self::fe_1(), |
@@ -1503,8 +1477,7 @@ discard block |
||
1503 | 1477 | * @param int $c |
1504 | 1478 | * @return int |
1505 | 1479 | */ |
1506 | - public static function equal($b, $c) |
|
1507 | - { |
|
1480 | + public static function equal($b, $c) { |
|
1508 | 1481 | return (int) ((($b ^ $c) - 1) >> 31) & 1; |
1509 | 1482 | } |
1510 | 1483 | |
@@ -1516,8 +1489,7 @@ discard block |
||
1516 | 1489 | * @throws SodiumException |
1517 | 1490 | * @throws TypeError |
1518 | 1491 | */ |
1519 | - public static function negative($char) |
|
1520 | - { |
|
1492 | + public static function negative($char) { |
|
1521 | 1493 | if (is_int($char)) { |
1522 | 1494 | return ($char >> 63) & 1; |
1523 | 1495 | } |
@@ -1576,8 +1548,7 @@ discard block |
||
1576 | 1548 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_Cached |
1577 | 1549 | * @throws SodiumException |
1578 | 1550 | */ |
1579 | - public static function ge_cmov8_cached(array $cached, $b) |
|
1580 | - { |
|
1551 | + public static function ge_cmov8_cached(array $cached, $b) { |
|
1581 | 1552 | // const unsigned char bnegative = negative(b); |
1582 | 1553 | // const unsigned char babs = b - (((-bnegative) & b) * ((signed char) 1 << 1)); |
1583 | 1554 | $bnegative = self::negative($b); |
@@ -1628,8 +1599,7 @@ discard block |
||
1628 | 1599 | * @psalm-suppress MixedArrayAccess |
1629 | 1600 | * @psalm-suppress MixedArrayOffset |
1630 | 1601 | */ |
1631 | - public static function ge_select($pos = 0, $b = 0) |
|
1632 | - { |
|
1602 | + public static function ge_select($pos = 0, $b = 0) { |
|
1633 | 1603 | static $base = null; |
1634 | 1604 | if ($base === null) { |
1635 | 1605 | $base = array(); |
@@ -1711,8 +1681,7 @@ discard block |
||
1711 | 1681 | * @throws SodiumException |
1712 | 1682 | * @throws TypeError |
1713 | 1683 | */ |
1714 | - public static function ge_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P2 $h) |
|
1715 | - { |
|
1684 | + public static function ge_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P2 $h) { |
|
1716 | 1685 | $recip = self::fe_invert($h->Z); |
1717 | 1686 | $x = self::fe_mul($h->X, $recip); |
1718 | 1687 | $y = self::fe_mul($h->Y, $recip); |
@@ -1861,8 +1830,7 @@ discard block |
||
1861 | 1830 | * @psalm-suppress MixedAssignment |
1862 | 1831 | * @psalm-suppress MixedOperand |
1863 | 1832 | */ |
1864 | - public static function ge_scalarmult($a, $p) |
|
1865 | - { |
|
1833 | + public static function ge_scalarmult($a, $p) { |
|
1866 | 1834 | $e = array_fill(0, 64, 0); |
1867 | 1835 | |
1868 | 1836 | /** @var ParagonIE_Sodium_Core_Curve25519_Ge_Cached[] $pi */ |
@@ -1999,8 +1967,7 @@ discard block |
||
1999 | 1967 | * @psalm-suppress MixedAssignment |
2000 | 1968 | * @psalm-suppress MixedOperand |
2001 | 1969 | */ |
2002 | - public static function ge_scalarmult_base($a) |
|
2003 | - { |
|
1970 | + public static function ge_scalarmult_base($a) { |
|
2004 | 1971 | /** @var array<int, int> $e */ |
2005 | 1972 | $e = array(); |
2006 | 1973 | $r = new ParagonIE_Sodium_Core_Curve25519_Ge_P1p1(); |
@@ -2059,8 +2026,7 @@ discard block |
||
2059 | 2026 | * @return string |
2060 | 2027 | * @throws TypeError |
2061 | 2028 | */ |
2062 | - public static function sc_muladd($a, $b, $c) |
|
2063 | - { |
|
2029 | + public static function sc_muladd($a, $b, $c) { |
|
2064 | 2030 | $a0 = 2097151 & self::load_3(self::substr($a, 0, 3)); |
2065 | 2031 | $a1 = 2097151 & (self::load_4(self::substr($a, 2, 4)) >> 5); |
2066 | 2032 | $a2 = 2097151 & (self::load_3(self::substr($a, 5, 3)) >> 2); |
@@ -2510,8 +2476,7 @@ discard block |
||
2510 | 2476 | * @return string |
2511 | 2477 | * @throws TypeError |
2512 | 2478 | */ |
2513 | - public static function sc_reduce($s) |
|
2514 | - { |
|
2479 | + public static function sc_reduce($s) { |
|
2515 | 2480 | $s0 = 2097151 & self::load_3(self::substr($s, 0, 3)); |
2516 | 2481 | $s1 = 2097151 & (self::load_4(self::substr($s, 2, 4)) >> 5); |
2517 | 2482 | $s2 = 2097151 & (self::load_3(self::substr($s, 5, 3)) >> 2); |
@@ -2827,8 +2792,7 @@ discard block |
||
2827 | 2792 | * @param ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A |
2828 | 2793 | * @return ParagonIE_Sodium_Core_Curve25519_Ge_P3 |
2829 | 2794 | */ |
2830 | - public static function ge_mul_l(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A) |
|
2831 | - { |
|
2795 | + public static function ge_mul_l(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A) { |
|
2832 | 2796 | $aslide = array( |
2833 | 2797 | 13, 0, 0, 0, 0, -1, 0, 0, 0, 0, -11, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, |
2834 | 2798 | 0, 0, 0, -3, 0, 0, 0, 0, -13, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 3, 0, |
@@ -2888,8 +2852,7 @@ discard block |
||
2888 | 2852 | * @param string $b |
2889 | 2853 | * @return string |
2890 | 2854 | */ |
2891 | - public static function sc25519_mul($a, $b) |
|
2892 | - { |
|
2855 | + public static function sc25519_mul($a, $b) { |
|
2893 | 2856 | // int64_t a0 = 2097151 & load_3(a); |
2894 | 2857 | // int64_t a1 = 2097151 & (load_4(a + 2) >> 5); |
2895 | 2858 | // int64_t a2 = 2097151 & (load_3(a + 5) >> 2); |
@@ -3703,8 +3666,7 @@ discard block |
||
3703 | 3666 | * @param string $s |
3704 | 3667 | * @return string |
3705 | 3668 | */ |
3706 | - public static function sc25519_sq($s) |
|
3707 | - { |
|
3669 | + public static function sc25519_sq($s) { |
|
3708 | 3670 | return self::sc25519_mul($s, $s); |
3709 | 3671 | } |
3710 | 3672 | |
@@ -3714,8 +3676,7 @@ discard block |
||
3714 | 3676 | * @param string $a |
3715 | 3677 | * @return string |
3716 | 3678 | */ |
3717 | - public static function sc25519_sqmul($s, $n, $a) |
|
3718 | - { |
|
3679 | + public static function sc25519_sqmul($s, $n, $a) { |
|
3719 | 3680 | for ($i = 0; $i < $n; ++$i) { |
3720 | 3681 | $s = self::sc25519_sq($s); |
3721 | 3682 | } |
@@ -3726,8 +3687,7 @@ discard block |
||
3726 | 3687 | * @param string $s |
3727 | 3688 | * @return string |
3728 | 3689 | */ |
3729 | - public static function sc25519_invert($s) |
|
3730 | - { |
|
3690 | + public static function sc25519_invert($s) { |
|
3731 | 3691 | $_10 = self::sc25519_sq($s); |
3732 | 3692 | $_11 = self::sc25519_mul($s, $_10); |
3733 | 3693 | $_100 = self::sc25519_mul($s, $_11); |
@@ -3774,8 +3734,7 @@ discard block |
||
3774 | 3734 | * @param string $s |
3775 | 3735 | * @return string |
3776 | 3736 | */ |
3777 | - public static function clamp($s) |
|
3778 | - { |
|
3737 | + public static function clamp($s) { |
|
3779 | 3738 | $s_ = self::stringToIntArray($s); |
3780 | 3739 | $s_[0] &= 248; |
3781 | 3740 | $s_[31] |= 64; |