@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public \GMP $num; |
10 | 10 | public \GMP $order; |
11 | 11 | |
12 | - public function __construct(\GMP|int $number, \GMP|int $order) |
|
12 | + public function __construct(\GMP | int $number, \GMP | int $order) |
|
13 | 13 | { |
14 | 14 | if ($number < 0 || $order <= $number) { |
15 | 15 | throw new \InvalidArgumentException("$number not in field range [0, $order)"); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return new static(($this->num * gmp_powm($divisor->num, $this->order - 2, $this->order)) % $this->order, $this->order); |
52 | 52 | } |
53 | 53 | |
54 | - public function exp(\GMP|int $exponent): static |
|
54 | + public function exp(\GMP | int $exponent): static |
|
55 | 55 | { |
56 | 56 | return new static(gmp_powm($this->num, $exponent % ($this->order - 1), $this->order), $this->order); |
57 | 57 | } |
@@ -9,12 +9,11 @@ |
||
9 | 9 | */ |
10 | 10 | final readonly class S256Field extends FieldElement |
11 | 11 | { |
12 | - public function __construct(\GMP|int|string $number) |
|
12 | + public function __construct(\GMP | int | string $number) |
|
13 | 13 | { |
14 | 14 | if (\is_string($number)) { |
15 | 15 | $number = str_starts_with($number, '0x') ? |
16 | - gmp_init($number) : |
|
17 | - gmp_import($number); |
|
16 | + gmp_init($number) : gmp_import($number); |
|
18 | 17 | } |
19 | 18 | |
20 | 19 | parent::__construct($number, S256Params::P()); |
@@ -38,8 +38,7 @@ discard block |
||
38 | 38 | $beta = $alpha->sqrt(); |
39 | 39 | |
40 | 40 | return "\x02" === $sec[0] ? |
41 | - new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) : |
|
42 | - new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta); |
|
41 | + new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) : new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta); |
|
43 | 42 | } |
44 | 43 | |
45 | 44 | public function address(bool $compressed = true, bool $testnet = true): string |
@@ -64,7 +63,7 @@ discard block |
||
64 | 63 | { |
65 | 64 | $sInv = gmp_powm($sig->s, S256Params::N() - 2, S256Params::N()); |
66 | 65 | |
67 | - $u = ($z * $sInv) % S256Params::N(); |
|
66 | + $u = ($z * $sInv) % S256Params::N(); |
|
68 | 67 | $v = ($sig->r * $sInv) % S256Params::N(); |
69 | 68 | |
70 | 69 | $R = S256Params::G()->scalarMul($u)->add($this->scalarMul($v)); |
@@ -72,7 +71,7 @@ discard block |
||
72 | 71 | return $R->x->num == $sig->r; |
73 | 72 | } |
74 | 73 | |
75 | - public function scalarMul(\GMP|int $coefficient): static |
|
74 | + public function scalarMul(\GMP | int $coefficient): static |
|
76 | 75 | { |
77 | 76 | // Optimization: reduce the coefficient before computing the multiplication |
78 | 77 | return parent::scalarMul($coefficient % S256Params::N()); |
@@ -71,7 +71,7 @@ |
||
71 | 71 | return new static($x, $y, $this->a, $this->b); |
72 | 72 | } |
73 | 73 | |
74 | - public function scalarMul(\GMP|int $coefficient): static |
|
74 | + public function scalarMul(\GMP | int $coefficient): static |
|
75 | 75 | { |
76 | 76 | $c = $coefficient instanceof \GMP ? $coefficient : gmp_init($coefficient); |
77 | 77 | $current = clone $this; |
@@ -102,10 +102,10 @@ |
||
102 | 102 | */ |
103 | 103 | private static function bip16Condition(array $cmds): bool |
104 | 104 | { |
105 | - return 3 === \count($cmds) |
|
105 | + return 3 === \count($cmds) |
|
106 | 106 | && $cmds[0] === OpCodes::OP_HASH160->value |
107 | 107 | && \is_string($cmds[1]) |
108 | - && 20 === \strlen($cmds[1]) |
|
108 | + && 20 === \strlen($cmds[1]) |
|
109 | 109 | && $cmds[2] === OpCodes::OP_EQUAL->value; |
110 | 110 | } |
111 | 111 | } |