Completed
Push — master ( 1e44a6...a4916f )
by Marcel
52s
created
src/ECC/S256Point.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,15 +57,14 @@  discard block
 block discarded – undo
57 57
         }
58 58
 
59 59
         $lam = $this->equals($other) ?
60
-            new S256Field(3)->mul($this->x->exp(2))->mul(new S256Field(2)->mul($this->y)->exp(S256Params::P() - 2)) :
61
-            $other->y->sub($this->y)->mul($other->x->sub($this->x)->exp(S256Params::P() - 2));
60
+            new S256Field(3)->mul($this->x->exp(2))->mul(new S256Field(2)->mul($this->y)->exp(S256Params::P() - 2)) : $other->y->sub($this->y)->mul($other->x->sub($this->x)->exp(S256Params::P() - 2));
62 61
 
63 62
         $x3 = $lam->mul($lam)->sub($this->x)->sub($other->x);
64 63
 
65 64
         return new self($x3, $this->x->sub($x3)->mul($lam)->sub($this->y));
66 65
     }
67 66
 
68
-    public function scalarMul(\GMP|int $coefficient): self
67
+    public function scalarMul(\GMP | int $coefficient): self
69 68
     {
70 69
         // Optimization: reduce the coefficient modulo N before computing the multiplication
71 70
         $c       = $coefficient % S256Params::N();
@@ -109,8 +108,7 @@  discard block
 block discarded – undo
109 108
         $beta  = $alpha->sqrt();
110 109
 
111 110
         return "\x02" === $sec[0] ?
112
-            new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) :
113
-            new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta);
111
+            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);
114 112
     }
115 113
 
116 114
     public function address(bool $compressed = true, Network $mode = Network::TESTNET): string
@@ -133,7 +131,7 @@  discard block
 block discarded – undo
133 131
     {
134 132
         $sInv = gmp_powm($sig->s, S256Params::N() - 2, S256Params::N());
135 133
 
136
-        $u = ($z * $sInv)      % S256Params::N();
134
+        $u = ($z * $sInv) % S256Params::N();
137 135
         $v = ($sig->r * $sInv) % S256Params::N();
138 136
 
139 137
         $R = S256Params::G()->scalarMul($u)->add($this->scalarMul($v));
Please login to merge, or discard this patch.