| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Jose\Component\Core\Util\Ecc; |
| 6 |
|
| 7 |
use Brick\Math\BigInteger; |
| 8 |
use Jose\Component\Core\Util\BigInteger as CoreBigInteger; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
final class Math |
| 14 |
{ |
| 15 |
public static function equals(BigInteger $first, BigInteger $other): bool |
| 16 |
{ |
| 17 |
return $first->isEqualTo($other); |
| 18 |
} |
| 19 |
|
| 20 |
public static function add(BigInteger $augend, BigInteger $addend): BigInteger |
| 21 |
{ |
| 22 |
return $augend->plus($addend); |
| 23 |
} |
| 24 |
|
| 25 |
public static function toString(BigInteger $value): string |
| 26 |
{ |
| 27 |
return $value->toBase(10); |
| 28 |
} |
| 29 |
|
| 30 |
public static function inverseMod(BigInteger $a, BigInteger $m): BigInteger |
| 31 |
{ |
| 32 |
return CoreBigInteger::createFromBigInteger($a)->modInverse(CoreBigInteger::createFromBigInteger($m))->get(); |
| 33 |
} |
| 34 |
|
| 35 |
public static function baseConvert(string $number, int $from, int $to): string |
| 36 |
{ |
| 37 |
return BigInteger::fromBase($number, $from)->toBase($to); |
| 38 |
} |
| 39 |
} |