Completed
Push — master ( b71231...e73b0b )
by Marcel
01:03
created
src/ECC/FieldElement.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/ECC/S256Field.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,12 +9,11 @@
 block discarded – undo
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());
Please login to merge, or discard this patch.
src/ECC/S256Point.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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());
Please login to merge, or discard this patch.
src/ECC/Point.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Tx/Script/Interpreter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,10 +102,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Tx/Script.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,10 +119,10 @@
 block discarded – undo
119 119
 
120 120
     public function isP2SH(): bool
121 121
     {
122
-        return 3              === \count($this->cmds)
122
+        return 3 === \count($this->cmds)
123 123
             && $this->cmds[0] === OpCodes::OP_HASH160->value
124 124
             && \is_string($this->cmds[1])
125
-            && 20             === \strlen($this->cmds[1])
125
+            && 20 === \strlen($this->cmds[1])
126 126
             && $this->cmds[2] === OpCodes::OP_EQUAL->value;
127 127
     }
128 128
 
Please login to merge, or discard this patch.