@@ -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; |
@@ -3,8 +3,7 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * Class ParagonIE_Sodium_Core_Ristretto255 |
| 5 | 5 | */ |
| 6 | -class ParagonIE_Sodium_Core_Ristretto255 extends ParagonIE_Sodium_Core_Ed25519 |
|
| 7 | -{ |
|
| 6 | +class ParagonIE_Sodium_Core_Ristretto255 extends ParagonIE_Sodium_Core_Ed25519 { |
|
| 8 | 7 | const crypto_core_ristretto255_HASHBYTES = 64; |
| 9 | 8 | const HASH_SC_L = 48; |
| 10 | 9 | const CORE_H2C_SHA256 = 1; |
@@ -15,8 +14,7 @@ discard block |
||
| 15 | 14 | * @param int $b |
| 16 | 15 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
| 17 | 16 | */ |
| 18 | - public static function fe_cneg(ParagonIE_Sodium_Core_Curve25519_Fe $f, $b) |
|
| 19 | - { |
|
| 17 | + public static function fe_cneg(ParagonIE_Sodium_Core_Curve25519_Fe $f, $b) { |
|
| 20 | 18 | $negf = self::fe_neg($f); |
| 21 | 19 | return self::fe_cmov($f, $negf, $b); |
| 22 | 20 | } |
@@ -26,8 +24,7 @@ discard block |
||
| 26 | 24 | * @return ParagonIE_Sodium_Core_Curve25519_Fe |
| 27 | 25 | * @throws SodiumException |
| 28 | 26 | */ |
| 29 | - public static function fe_abs(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
| 30 | - { |
|
| 27 | + public static function fe_abs(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
| 31 | 28 | return self::fe_cneg($f, self::fe_isnegative($f)); |
| 32 | 29 | } |
| 33 | 30 | |
@@ -40,8 +37,7 @@ discard block |
||
| 40 | 37 | * @return int |
| 41 | 38 | * @throws SodiumException |
| 42 | 39 | */ |
| 43 | - public static function fe_iszero(ParagonIE_Sodium_Core_Curve25519_Fe $f) |
|
| 44 | - { |
|
| 40 | + public static function fe_iszero(ParagonIE_Sodium_Core_Curve25519_Fe $f) { |
|
| 45 | 41 | static $zero; |
| 46 | 42 | if ($zero === null) { |
| 47 | 43 | $zero = str_repeat("\x00", 32); |
@@ -120,8 +116,7 @@ discard block |
||
| 120 | 116 | * @return int |
| 121 | 117 | * @throws SodiumException |
| 122 | 118 | */ |
| 123 | - public static function ristretto255_point_is_canonical($s) |
|
| 124 | - { |
|
| 119 | + public static function ristretto255_point_is_canonical($s) { |
|
| 125 | 120 | $c = (self::chrToInt($s[31]) & 0x7f) ^ 0x7f; |
| 126 | 121 | for ($i = 30; $i > 0; --$i) { |
| 127 | 122 | $c |= self::chrToInt($s[$i]) ^ 0xff; |
@@ -139,8 +134,7 @@ discard block |
||
| 139 | 134 | * @return array{h: ParagonIE_Sodium_Core_Curve25519_Ge_P3, res: int} |
| 140 | 135 | * @throws SodiumException |
| 141 | 136 | */ |
| 142 | - public static function ristretto255_frombytes($s, $skipCanonicalCheck = false) |
|
| 143 | - { |
|
| 137 | + public static function ristretto255_frombytes($s, $skipCanonicalCheck = false) { |
|
| 144 | 138 | if (!$skipCanonicalCheck) { |
| 145 | 139 | if (!self::ristretto255_point_is_canonical($s)) { |
| 146 | 140 | throw new SodiumException('S is not canonical'); |
@@ -193,8 +187,7 @@ discard block |
||
| 193 | 187 | * @return string |
| 194 | 188 | * @throws SodiumException |
| 195 | 189 | */ |
| 196 | - public static function ristretto255_p3_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $h) |
|
| 197 | - { |
|
| 190 | + public static function ristretto255_p3_tobytes(ParagonIE_Sodium_Core_Curve25519_Ge_P3 $h) { |
|
| 198 | 191 | $sqrtm1 = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$sqrtm1); |
| 199 | 192 | $invsqrtamd = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$invsqrtamd); |
| 200 | 193 | |
@@ -254,8 +247,7 @@ discard block |
||
| 254 | 247 | * |
| 255 | 248 | * @throws SodiumException |
| 256 | 249 | */ |
| 257 | - public static function ristretto255_elligator(ParagonIE_Sodium_Core_Curve25519_Fe $t) |
|
| 258 | - { |
|
| 250 | + public static function ristretto255_elligator(ParagonIE_Sodium_Core_Curve25519_Fe $t) { |
|
| 259 | 251 | $sqrtm1 = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$sqrtm1); |
| 260 | 252 | $onemsqd = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$onemsqd); |
| 261 | 253 | $d = ParagonIE_Sodium_Core_Curve25519_Fe::fromArray(self::$d); |
@@ -326,8 +318,7 @@ discard block |
||
| 326 | 318 | * @return string |
| 327 | 319 | * @throws SodiumException |
| 328 | 320 | */ |
| 329 | - public static function ristretto255_from_hash($h) |
|
| 330 | - { |
|
| 321 | + public static function ristretto255_from_hash($h) { |
|
| 331 | 322 | if (self::strlen($h) !== 64) { |
| 332 | 323 | throw new SodiumException('Hash must be 64 bytes'); |
| 333 | 324 | } |
@@ -360,8 +351,7 @@ discard block |
||
| 360 | 351 | * @return int |
| 361 | 352 | * @throws SodiumException |
| 362 | 353 | */ |
| 363 | - public static function is_valid_point($p) |
|
| 364 | - { |
|
| 354 | + public static function is_valid_point($p) { |
|
| 365 | 355 | $result = self::ristretto255_frombytes($p); |
| 366 | 356 | if ($result['res'] !== 0) { |
| 367 | 357 | return 0; |
@@ -375,8 +365,7 @@ discard block |
||
| 375 | 365 | * @return string |
| 376 | 366 | * @throws SodiumException |
| 377 | 367 | */ |
| 378 | - public static function ristretto255_add($p, $q) |
|
| 379 | - { |
|
| 368 | + public static function ristretto255_add($p, $q) { |
|
| 380 | 369 | $p_res = self::ristretto255_frombytes($p); |
| 381 | 370 | $q_res = self::ristretto255_frombytes($q); |
| 382 | 371 | if ($p_res['res'] !== 0 || $q_res['res'] !== 0) { |
@@ -396,8 +385,7 @@ discard block |
||
| 396 | 385 | * @return string |
| 397 | 386 | * @throws SodiumException |
| 398 | 387 | */ |
| 399 | - public static function ristretto255_sub($p, $q) |
|
| 400 | - { |
|
| 388 | + public static function ristretto255_sub($p, $q) { |
|
| 401 | 389 | $p_res = self::ristretto255_frombytes($p); |
| 402 | 390 | $q_res = self::ristretto255_frombytes($q); |
| 403 | 391 | if ($p_res['res'] !== 0 || $q_res['res'] !== 0) { |
@@ -420,8 +408,7 @@ discard block |
||
| 420 | 408 | * @throws SodiumException |
| 421 | 409 | * @psalm-suppress PossiblyInvalidArgument hash API |
| 422 | 410 | */ |
| 423 | - protected static function h2c_string_to_hash_sha256($hLen, $ctx, $msg) |
|
| 424 | - { |
|
| 411 | + protected static function h2c_string_to_hash_sha256($hLen, $ctx, $msg) { |
|
| 425 | 412 | $h = array_fill(0, $hLen, 0); |
| 426 | 413 | $ctx_len = !is_null($ctx) ? self::strlen($ctx) : 0; |
| 427 | 414 | if ($hLen > 0xff) { |
@@ -470,8 +457,7 @@ discard block |
||
| 470 | 457 | * @throws SodiumException |
| 471 | 458 | * @psalm-suppress PossiblyInvalidArgument hash API |
| 472 | 459 | */ |
| 473 | - protected static function h2c_string_to_hash_sha512($hLen, $ctx, $msg) |
|
| 474 | - { |
|
| 460 | + protected static function h2c_string_to_hash_sha512($hLen, $ctx, $msg) { |
|
| 475 | 461 | $h = array_fill(0, $hLen, 0); |
| 476 | 462 | $ctx_len = !is_null($ctx) ? self::strlen($ctx) : 0; |
| 477 | 463 | if ($hLen > 0xff) { |
@@ -520,8 +506,7 @@ discard block |
||
| 520 | 506 | * @return string |
| 521 | 507 | * @throws SodiumException |
| 522 | 508 | */ |
| 523 | - public static function h2c_string_to_hash($hLen, $ctx, $msg, $hash_alg) |
|
| 524 | - { |
|
| 509 | + public static function h2c_string_to_hash($hLen, $ctx, $msg, $hash_alg) { |
|
| 525 | 510 | switch ($hash_alg) { |
| 526 | 511 | case self::CORE_H2C_SHA256: |
| 527 | 512 | return self::h2c_string_to_hash_sha256($hLen, $ctx, $msg); |
@@ -539,8 +524,7 @@ discard block |
||
| 539 | 524 | * @return string |
| 540 | 525 | * @throws SodiumException |
| 541 | 526 | */ |
| 542 | - protected static function _string_to_element($ctx, $msg, $hash_alg) |
|
| 543 | - { |
|
| 527 | + protected static function _string_to_element($ctx, $msg, $hash_alg) { |
|
| 544 | 528 | return self::ristretto255_from_hash( |
| 545 | 529 | self::h2c_string_to_hash(self::crypto_core_ristretto255_HASHBYTES, $ctx, $msg, $hash_alg) |
| 546 | 530 | ); |
@@ -551,8 +535,7 @@ discard block |
||
| 551 | 535 | * @throws SodiumException |
| 552 | 536 | * @throws Exception |
| 553 | 537 | */ |
| 554 | - public static function ristretto255_random() |
|
| 555 | - { |
|
| 538 | + public static function ristretto255_random() { |
|
| 556 | 539 | return self::ristretto255_from_hash( |
| 557 | 540 | ParagonIE_Sodium_Compat::randombytes_buf(self::crypto_core_ristretto255_HASHBYTES) |
| 558 | 541 | ); |
@@ -562,8 +545,7 @@ discard block |
||
| 562 | 545 | * @return string |
| 563 | 546 | * @throws SodiumException |
| 564 | 547 | */ |
| 565 | - public static function ristretto255_scalar_random() |
|
| 566 | - { |
|
| 548 | + public static function ristretto255_scalar_random() { |
|
| 567 | 549 | return self::scalar_random(); |
| 568 | 550 | } |
| 569 | 551 | |
@@ -572,8 +554,7 @@ discard block |
||
| 572 | 554 | * @return string |
| 573 | 555 | * @throws SodiumException |
| 574 | 556 | */ |
| 575 | - public static function ristretto255_scalar_complement($s) |
|
| 576 | - { |
|
| 557 | + public static function ristretto255_scalar_complement($s) { |
|
| 577 | 558 | return self::scalar_complement($s); |
| 578 | 559 | } |
| 579 | 560 | |
@@ -582,8 +563,7 @@ discard block |
||
| 582 | 563 | * @param string $s |
| 583 | 564 | * @return string |
| 584 | 565 | */ |
| 585 | - public static function ristretto255_scalar_invert($s) |
|
| 586 | - { |
|
| 566 | + public static function ristretto255_scalar_invert($s) { |
|
| 587 | 567 | return self::sc25519_invert($s); |
| 588 | 568 | } |
| 589 | 569 | |
@@ -592,8 +572,7 @@ discard block |
||
| 592 | 572 | * @return string |
| 593 | 573 | * @throws SodiumException |
| 594 | 574 | */ |
| 595 | - public static function ristretto255_scalar_negate($s) |
|
| 596 | - { |
|
| 575 | + public static function ristretto255_scalar_negate($s) { |
|
| 597 | 576 | return self::scalar_negate($s); |
| 598 | 577 | } |
| 599 | 578 | |
@@ -602,8 +581,7 @@ discard block |
||
| 602 | 581 | * @param string $y |
| 603 | 582 | * @return string |
| 604 | 583 | */ |
| 605 | - public static function ristretto255_scalar_add($x, $y) |
|
| 606 | - { |
|
| 584 | + public static function ristretto255_scalar_add($x, $y) { |
|
| 607 | 585 | return self::scalar_add($x, $y); |
| 608 | 586 | } |
| 609 | 587 | |
@@ -612,8 +590,7 @@ discard block |
||
| 612 | 590 | * @param string $y |
| 613 | 591 | * @return string |
| 614 | 592 | */ |
| 615 | - public static function ristretto255_scalar_sub($x, $y) |
|
| 616 | - { |
|
| 593 | + public static function ristretto255_scalar_sub($x, $y) { |
|
| 617 | 594 | return self::scalar_sub($x, $y); |
| 618 | 595 | } |
| 619 | 596 | |
@@ -622,8 +599,7 @@ discard block |
||
| 622 | 599 | * @param string $y |
| 623 | 600 | * @return string |
| 624 | 601 | */ |
| 625 | - public static function ristretto255_scalar_mul($x, $y) |
|
| 626 | - { |
|
| 602 | + public static function ristretto255_scalar_mul($x, $y) { |
|
| 627 | 603 | return self::sc25519_mul($x, $y); |
| 628 | 604 | } |
| 629 | 605 | |
@@ -634,8 +610,7 @@ discard block |
||
| 634 | 610 | * @return string |
| 635 | 611 | * @throws SodiumException |
| 636 | 612 | */ |
| 637 | - public static function ristretto255_scalar_from_string($ctx, $msg, $hash_alg) |
|
| 638 | - { |
|
| 613 | + public static function ristretto255_scalar_from_string($ctx, $msg, $hash_alg) { |
|
| 639 | 614 | $h = array_fill(0, 64, 0); |
| 640 | 615 | $h_be = self::stringToIntArray( |
| 641 | 616 | self::h2c_string_to_hash( |
@@ -653,8 +628,7 @@ discard block |
||
| 653 | 628 | * @param string $s |
| 654 | 629 | * @return string |
| 655 | 630 | */ |
| 656 | - public static function ristretto255_scalar_reduce($s) |
|
| 657 | - { |
|
| 631 | + public static function ristretto255_scalar_reduce($s) { |
|
| 658 | 632 | return self::sc_reduce($s); |
| 659 | 633 | } |
| 660 | 634 | |
@@ -664,8 +638,7 @@ discard block |
||
| 664 | 638 | * @return string |
| 665 | 639 | * @throws SodiumException |
| 666 | 640 | */ |
| 667 | - public static function scalarmult_ristretto255($n, $p) |
|
| 668 | - { |
|
| 641 | + public static function scalarmult_ristretto255($n, $p) { |
|
| 669 | 642 | if (self::strlen($n) !== 32) { |
| 670 | 643 | throw new SodiumException('Scalar must be 32 bytes, ' . self::strlen($p) . ' given.'); |
| 671 | 644 | } |
@@ -693,8 +666,7 @@ discard block |
||
| 693 | 666 | * @return string |
| 694 | 667 | * @throws SodiumException |
| 695 | 668 | */ |
| 696 | - public static function scalarmult_ristretto255_base($n) |
|
| 697 | - { |
|
| 669 | + public static function scalarmult_ristretto255_base($n) { |
|
| 698 | 670 | $t = self::stringToIntArray($n); |
| 699 | 671 | $t[31] &= 0x7f; |
| 700 | 672 | $Q = self::ge_scalarmult_base(self::intArrayToString($t)); |