Completed
Push — master ( 93687c...b11899 )
by Marcel
57s
created
src/ECC/S256Point.php 1 patch
Spacing   +4 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,15 +66,14 @@  discard block
 block discarded – undo
66 66
         }
67 67
 
68 68
         $lam = $this->equals($other) ?
69
-            new S256Field(3)->mul($this->x->exp(2))->mul(new S256Field(2)->mul($this->y)->exp(S256Params::P() - 2)) :
70
-            $other->y->sub($this->y)->mul($other->x->sub($this->x)->exp(S256Params::P() - 2));
69
+            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));
71 70
 
72 71
         $x3 = $lam->mul($lam)->sub($this->x)->sub($other->x);
73 72
 
74 73
         return new self($x3, $this->x->sub($x3)->mul($lam)->sub($this->y));
75 74
     }
76 75
 
77
-    public function scalarMul(\GMP|int $coefficient): self
76
+    public function scalarMul(\GMP | int $coefficient): self
78 77
     {
79 78
         // Optimization: reduce the coefficient modulo N before computing the multiplication
80 79
         $c       = $coefficient % S256Params::N();
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
         $beta  = $alpha->sqrt();
131 130
 
132 131
         return "\x02" === $sec[0] ?
133
-            new self($x, (0 == $beta->num % 2) ? $beta : new S256Field(S256Params::P() - $beta->num)) :
134
-            new self($x, (0 == $beta->num % 2) ? new S256Field(S256Params::P() - $beta->num) : $beta);
132
+            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);
135 133
     }
136 134
 
137 135
     public function sec(bool $compressed = true): string
@@ -157,7 +155,7 @@  discard block
 block discarded – undo
157 155
     {
158 156
         $sInv = gmp_powm($sig->s, S256Params::N() - 2, S256Params::N());
159 157
 
160
-        $u = ($z * $sInv)      % S256Params::N();
158
+        $u = ($z * $sInv) % S256Params::N();
161 159
         $v = ($sig->r * $sInv) % S256Params::N();
162 160
 
163 161
         $R = S256Params::G()->scalarMul($u)->add($this->scalarMul($v));
Please login to merge, or discard this patch.