-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMath.php
More file actions
39 lines (31 loc) · 954 Bytes
/
Math.php
File metadata and controls
39 lines (31 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace Jose\Component\Core\Util\Ecc;
use Brick\Math\BigInteger;
use Jose\Component\Core\Util\BigInteger as CoreBigInteger;
/**
* @internal
*/
final class Math
{
public static function equals(BigInteger $first, BigInteger $other): bool
{
return $first->isEqualTo($other);
}
public static function add(BigInteger $augend, BigInteger $addend): BigInteger
{
return $augend->plus($addend);
}
public static function toString(BigInteger $value): string
{
return $value->toBase(10);
}
public static function inverseMod(BigInteger $a, BigInteger $m): BigInteger
{
return CoreBigInteger::createFromBigInteger($a)->modInverse(CoreBigInteger::createFromBigInteger($m))->get();
}
public static function baseConvert(string $number, int $from, int $to): string
{
return BigInteger::fromBase($number, $from)->toBase($to);
}
}