@@ -133,7 +133,7 @@  | 
                                                    ||
| 133 | 133 | /**  | 
                                                        
| 134 | 134 | * Ensures the decoded PEM key lengths are acceptable.  | 
                                                        
| 135 | 135 | *  | 
                                                        
| 136 | - * @param array $values The key values to check.  | 
                                                        |
| 136 | + * @param string[] $values The key values to check.  | 
                                                        |
| 137 | 137 | * @throws \Exception  | 
                                                        
| 138 | 138 | */  | 
                                                        
| 139 | 139 | private function pemKeyLenCheck($values)  | 
                                                        
@@ -45,25 +45,25 @@ discard block  | 
                                                    ||
| 45 | 45 | $this->pemInitialDataCheck($keypair);  | 
                                                        
| 46 | 46 | |
| 47 | 47 | $ecpemstruct = array(  | 
                                                        
| 48 | - 'sequence_beg' => '30',  | 
                                                        |
| 49 | - 'total_len' => '74',  | 
                                                        |
| 50 | - 'int_sec_beg' => '02',  | 
                                                        |
| 51 | - 'int_sec_len' => '01',  | 
                                                        |
| 52 | - 'int_sec_val' => '01',  | 
                                                        |
| 53 | - 'oct_sec_beg' => '04',  | 
                                                        |
| 54 | - 'oct_sec_len' => '20',  | 
                                                        |
| 55 | - 'oct_sec_val' => $keypair[0],  | 
                                                        |
| 56 | - 'a0_ele_beg' => 'a0',  | 
                                                        |
| 57 | - 'a0_ele_len' => '07',  | 
                                                        |
| 58 | - 'obj_id_beg' => '06',  | 
                                                        |
| 59 | - 'obj_id_len' => '05',  | 
                                                        |
| 60 | - 'obj_id_val' => '2b8104000a',  | 
                                                        |
| 61 | - 'a1_ele_beg' => 'a1',  | 
                                                        |
| 62 | - 'a1_ele_len' => '44',  | 
                                                        |
| 63 | - 'bit_str_beg' => '03',  | 
                                                        |
| 64 | - 'bit_str_len' => '42',  | 
                                                        |
| 65 | - 'bit_str_val' => '00' . $keypair[1],  | 
                                                        |
| 66 | - );  | 
                                                        |
| 48 | + 'sequence_beg' => '30',  | 
                                                        |
| 49 | + 'total_len' => '74',  | 
                                                        |
| 50 | + 'int_sec_beg' => '02',  | 
                                                        |
| 51 | + 'int_sec_len' => '01',  | 
                                                        |
| 52 | + 'int_sec_val' => '01',  | 
                                                        |
| 53 | + 'oct_sec_beg' => '04',  | 
                                                        |
| 54 | + 'oct_sec_len' => '20',  | 
                                                        |
| 55 | + 'oct_sec_val' => $keypair[0],  | 
                                                        |
| 56 | + 'a0_ele_beg' => 'a0',  | 
                                                        |
| 57 | + 'a0_ele_len' => '07',  | 
                                                        |
| 58 | + 'obj_id_beg' => '06',  | 
                                                        |
| 59 | + 'obj_id_len' => '05',  | 
                                                        |
| 60 | + 'obj_id_val' => '2b8104000a',  | 
                                                        |
| 61 | + 'a1_ele_beg' => 'a1',  | 
                                                        |
| 62 | + 'a1_ele_len' => '44',  | 
                                                        |
| 63 | + 'bit_str_beg' => '03',  | 
                                                        |
| 64 | + 'bit_str_len' => '42',  | 
                                                        |
| 65 | + 'bit_str_val' => '00' . $keypair[1],  | 
                                                        |
| 66 | + );  | 
                                                        |
| 67 | 67 | |
| 68 | 68 | $dec = trim(implode($ecpemstruct));  | 
                                                        
| 69 | 69 | |
@@ -86,9 +86,9 @@ discard block  | 
                                                    ||
| 86 | 86 | $this->pemDataLenCheck($decoded);  | 
                                                        
| 87 | 87 | |
| 88 | 88 | $ecpemstruct = array(  | 
                                                        
| 89 | - 'oct_sec_val' => substr($decoded, 14, 64),  | 
                                                        |
| 90 | - 'obj_id_val' => substr($decoded, 86, 10),  | 
                                                        |
| 91 | - 'bit_str_val' => substr($decoded, 106),  | 
                                                        |
| 89 | + 'oct_sec_val' => substr($decoded, 14, 64),  | 
                                                        |
| 90 | + 'obj_id_val' => substr($decoded, 86, 10),  | 
                                                        |
| 91 | + 'bit_str_val' => substr($decoded, 106),  | 
                                                        |
| 92 | 92 | );  | 
                                                        
| 93 | 93 | |
| 94 | 94 | $this->pemOidCheck($ecpemstruct['obj_id_val']);  | 
                                                        
@@ -99,8 +99,8 @@ discard block  | 
                                                    ||
| 99 | 99 | $this->pemKeyLenCheck(array($private_key, $public_key));  | 
                                                        
| 100 | 100 | |
| 101 | 101 | return array(  | 
                                                        
| 102 | - 'private_key' => $private_key,  | 
                                                        |
| 103 | - 'public_key' => $public_key  | 
                                                        |
| 102 | + 'private_key' => $private_key,  | 
                                                        |
| 103 | + 'public_key' => $public_key  | 
                                                        |
| 104 | 104 | );  | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
@@ -320,7 +320,7 @@  | 
                                                    ||
| 320 | 320 | *  | 
                                                        
| 321 | 321 | * @param string $num Number parameter.  | 
                                                        
| 322 | 322 | * @param string $mod Modulo parameter.  | 
                                                        
| 323 | - * @return array Array of num % mod, num / mod.  | 
                                                        |
| 323 | + * @return string[] Array of num % mod, num / mod.  | 
                                                        |
| 324 | 324 | */  | 
                                                        
| 325 | 325 | public function modDiv($num, $mod)  | 
                                                        
| 326 | 326 |      { | 
                                                        
@@ -240,7 +240,7 @@  | 
                                                    ||
| 240 | 240 | case 'unk':  | 
                                                        
| 241 | 241 |              throw new \Exception('Unknown number type in BC::bcNormalize().  Cannot process!'); | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | - **/  | 
                                                        |
| 243 | + **/  | 
                                                        |
| 244 | 244 | |
| 245 | 245 | return $a;  | 
                                                        
| 246 | 246 | }  | 
                                                        
@@ -81,12 +81,12 @@  | 
                                                    ||
| 81 | 81 | public function __toString()  | 
                                                        
| 82 | 82 |      { | 
                                                        
| 83 | 83 | return json_encode(array(  | 
                                                        
| 84 | - 'WIF_address' => $this->WIF_address,  | 
                                                        |
| 85 | - 'private_key' => $this->private_key,  | 
                                                        |
| 86 | - 'network_type' => $this->network_type,  | 
                                                        |
| 87 | - 'compressed_pubkey' => $this->compressed_pubkey_format,  | 
                                                        |
| 88 | - 'checksum' => $this->checksum)  | 
                                                        |
| 89 | - );  | 
                                                        |
| 84 | + 'WIF_address' => $this->WIF_address,  | 
                                                        |
| 85 | + 'private_key' => $this->private_key,  | 
                                                        |
| 86 | + 'network_type' => $this->network_type,  | 
                                                        |
| 87 | + 'compressed_pubkey' => $this->compressed_pubkey_format,  | 
                                                        |
| 88 | + 'checksum' => $this->checksum)  | 
                                                        |
| 89 | + );  | 
                                                        |
| 90 | 90 | }  | 
                                                        
| 91 | 91 | |
| 92 | 92 | /**  | 
                                                        
@@ -383,7 +383,7 @@  | 
                                                    ||
| 383 | 383 | |
| 384 | 384 | $private_key = substr($private_key, 2);  | 
                                                        
| 385 | 385 | |
| 386 | - $compressed_public_key = (substr($private_key, strlen($private_key) - 2) == '01') ? '01': '';  | 
                                                        |
| 386 | + $compressed_public_key = (substr($private_key, strlen($private_key) - 2) == '01') ? '01' : '';  | 
                                                        |
| 387 | 387 | |
| 388 | 388 | $private_key = ($compressed_public_key == '01') ? substr($private_key, 0, -2) : $private_key;  | 
                                                        
| 389 | 389 | |
@@ -49,14 +49,14 @@ discard block  | 
                                                    ||
| 49 | 49 | public function __construct(array $params = null)  | 
                                                        
| 50 | 50 |      { | 
                                                        
| 51 | 51 | $this->keyInfo = array(  | 
                                                        
| 52 | - 'private_key_hex' => $this->keyValueCheck($params['private_key_hex']),  | 
                                                        |
| 53 | - 'private_key_dec' => $this->keyValueCheck($params['private_key_dec']),  | 
                                                        |
| 54 | - 'public_key' => $this->keyValueCheck($params['public_key']),  | 
                                                        |
| 55 | - 'public_key_compressed' => $this->keyValueCheck($params['public_key_compressed']),  | 
                                                        |
| 56 | - 'public_key_x' => $this->keyValueCheck($params['public_key_x']),  | 
                                                        |
| 57 | - 'public_key_y' => $this->keyValueCheck($params['public_key_y']),  | 
                                                        |
| 58 | - 'generation_time' => '',  | 
                                                        |
| 59 | - );  | 
                                                        |
| 52 | + 'private_key_hex' => $this->keyValueCheck($params['private_key_hex']),  | 
                                                        |
| 53 | + 'private_key_dec' => $this->keyValueCheck($params['private_key_dec']),  | 
                                                        |
| 54 | + 'public_key' => $this->keyValueCheck($params['public_key']),  | 
                                                        |
| 55 | + 'public_key_compressed' => $this->keyValueCheck($params['public_key_compressed']),  | 
                                                        |
| 56 | + 'public_key_x' => $this->keyValueCheck($params['public_key_x']),  | 
                                                        |
| 57 | + 'public_key_y' => $this->keyValueCheck($params['public_key_y']),  | 
                                                        |
| 58 | + 'generation_time' => '',  | 
                                                        |
| 59 | + );  | 
                                                        |
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
| 62 | 62 | /**  | 
                                                        
@@ -117,13 +117,13 @@ discard block  | 
                                                    ||
| 117 | 117 | $comp_prefix = ($this->Modulo($point['R']['y'], '2') == '1') ? '03' : '02';  | 
                                                        
| 118 | 118 | |
| 119 | 119 | $this->keyInfo = array(  | 
                                                        
| 120 | - 'private_key_hex' => $this->encodeHex($point['random_number']),  | 
                                                        |
| 121 | - 'private_key_dec' => $point['random_number'],  | 
                                                        |
| 122 | - 'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'],  | 
                                                        |
| 123 | - 'public_key_compressed' => $comp_prefix . $point['Rx_hex'],  | 
                                                        |
| 124 | - 'public_key_x' => $point['Rx_hex'],  | 
                                                        |
| 125 | - 'public_key_y' => $point['Ry_hex'],  | 
                                                        |
| 126 | - );  | 
                                                        |
| 120 | + 'private_key_hex' => $this->encodeHex($point['random_number']),  | 
                                                        |
| 121 | + 'private_key_dec' => $point['random_number'],  | 
                                                        |
| 122 | + 'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'],  | 
                                                        |
| 123 | + 'public_key_compressed' => $comp_prefix . $point['Rx_hex'],  | 
                                                        |
| 124 | + 'public_key_x' => $point['Rx_hex'],  | 
                                                        |
| 125 | + 'public_key_y' => $point['Ry_hex'],  | 
                                                        |
| 126 | + );  | 
                                                        |
| 127 | 127 | |
| 128 | 128 | return $this->keyInfo;  | 
                                                        
| 129 | 129 | }  | 
                                                        
@@ -81,8 +81,8 @@ discard block  | 
                                                    ||
| 81 | 81 | $this->raw_signature = '';  | 
                                                        
| 82 | 82 | |
| 83 | 83 | $this->P = array(  | 
                                                        
| 84 | - 'x' => $this->Gx,  | 
                                                        |
| 85 | - 'y' => $this->Gy  | 
                                                        |
| 84 | + 'x' => $this->Gx,  | 
                                                        |
| 85 | + 'y' => $this->Gy  | 
                                                        |
| 86 | 86 | );  | 
                                                        
| 87 | 87 | |
| 88 | 88 | $this->keyUtil = new \Phactor\Key;  | 
                                                        
@@ -149,9 +149,9 @@ discard block  | 
                                                    ||
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
| 151 | 151 | $signature = array(  | 
                                                        
| 152 | - 'r' => $this->addHexPrefix(str_pad($this->encodeHex($r, false), 64, "0", STR_PAD_LEFT)),  | 
                                                        |
| 153 | - 's' => $this->addHexPrefix(str_pad($this->encodeHex($s, false), 64, "0", STR_PAD_LEFT))  | 
                                                        |
| 154 | - );  | 
                                                        |
| 152 | + 'r' => $this->addHexPrefix(str_pad($this->encodeHex($r, false), 64, "0", STR_PAD_LEFT)),  | 
                                                        |
| 153 | + 's' => $this->addHexPrefix(str_pad($this->encodeHex($s, false), 64, "0", STR_PAD_LEFT))  | 
                                                        |
| 154 | + );  | 
                                                        |
| 155 | 155 | |
| 156 | 156 | $this->r_coordinate = $signature['r'];  | 
                                                        
| 157 | 157 | $this->s_coordinate = $signature['s'];  | 
                                                        
@@ -248,10 +248,10 @@ discard block  | 
                                                    ||
| 248 | 248 | $retval = array(  | 
                                                        
| 249 | 249 | 'bin_r' => $this->msbCheck($r[0]) . $r,  | 
                                                        
| 250 | 250 | 'bin_s' => $this->msbCheck($s[0]) . $s  | 
                                                        
| 251 | - );  | 
                                                        |
| 251 | + );  | 
                                                        |
| 252 | 252 | |
| 253 | 253 | $seq = chr(0x02) . chr(strlen($retval['bin_r'])) . $retval['bin_r'] .  | 
                                                        
| 254 | - chr(0x02) . chr(strlen($retval['bin_s'])) . $retval['bin_s'];  | 
                                                        |
| 254 | + chr(0x02) . chr(strlen($retval['bin_s'])) . $retval['bin_s'];  | 
                                                        |
| 255 | 255 | |
| 256 | 256 | return bin2hex(chr(0x30) . chr(strlen($seq)) . $seq);  | 
                                                        
| 257 | 257 | }  | 
                                                        
@@ -270,19 +270,19 @@ discard block  | 
                                                    ||
| 270 | 270 | |
| 271 | 271 | /* This is the main structure we'll use for storing our parsed signature. */  | 
                                                        
| 272 | 272 | $ecdsa_struct = array(  | 
                                                        
| 273 | - 'sigstart' => '',  | 
                                                        |
| 274 | - 'siglen' => '',  | 
                                                        |
| 275 | - 'rtype' => '',  | 
                                                        |
| 276 | - 'rlen' => '',  | 
                                                        |
| 277 | - 'roffset' => 0,  | 
                                                        |
| 278 | - 'r' => '',  | 
                                                        |
| 279 | - 'stype' => '',  | 
                                                        |
| 280 | - 'slen' => '',  | 
                                                        |
| 281 | - 'soffset' => 0,  | 
                                                        |
| 282 | - 's' => '',  | 
                                                        |
| 283 | - 'original' => '',  | 
                                                        |
| 284 | - 'totallen' => 0  | 
                                                        |
| 285 | - );  | 
                                                        |
| 273 | + 'sigstart' => '',  | 
                                                        |
| 274 | + 'siglen' => '',  | 
                                                        |
| 275 | + 'rtype' => '',  | 
                                                        |
| 276 | + 'rlen' => '',  | 
                                                        |
| 277 | + 'roffset' => 0,  | 
                                                        |
| 278 | + 'r' => '',  | 
                                                        |
| 279 | + 'stype' => '',  | 
                                                        |
| 280 | + 'slen' => '',  | 
                                                        |
| 281 | + 'soffset' => 0,  | 
                                                        |
| 282 | + 's' => '',  | 
                                                        |
| 283 | + 'original' => '',  | 
                                                        |
| 284 | + 'totallen' => 0  | 
                                                        |
| 285 | + );  | 
                                                        |
| 286 | 286 | |
| 287 | 287 | $ecdsa_struct['original'] = $signature;  | 
                                                        
| 288 | 288 | $ecdsa_struct['totallen'] = strlen($signature);  | 
                                                        
@@ -333,8 +333,8 @@ discard block  | 
                                                    ||
| 333 | 333 | $this->RangeCheck($ecdsa_struct['r']);  | 
                                                        
| 334 | 334 | |
| 335 | 335 | return array(  | 
                                                        
| 336 | - 'r' => $ecdsa_struct['r'],  | 
                                                        |
| 337 | - 's' => $ecdsa_struct['s']  | 
                                                        |
| 336 | + 'r' => $ecdsa_struct['r'],  | 
                                                        |
| 337 | + 's' => $ecdsa_struct['s']  | 
                                                        |
| 338 | 338 | );  | 
                                                        
| 339 | 339 | }  | 
                                                        
| 340 | 340 | |
@@ -267,9 +267,9 @@ discard block  | 
                                                    ||
| 267 | 267 | public function GenerateNewPoint($ladder = true)  | 
                                                        
| 268 | 268 |      { | 
                                                        
| 269 | 269 | $P = array(  | 
                                                        
| 270 | - 'x' => $this->Gx,  | 
                                                        |
| 271 | - 'y' => $this->Gy  | 
                                                        |
| 272 | - );  | 
                                                        |
| 270 | + 'x' => $this->Gx,  | 
                                                        |
| 271 | + 'y' => $this->Gy  | 
                                                        |
| 272 | + );  | 
                                                        |
| 273 | 273 | |
| 274 | 274 |          do { | 
                                                        
| 275 | 275 | $random_number = $this->SecureRandomNumber();  | 
                                                        
@@ -285,10 +285,10 @@ discard block  | 
                                                    ||
| 285 | 285 | }  | 
                                                        
| 286 | 286 | |
| 287 | 287 | return array(  | 
                                                        
| 288 | - 'random_number' => $random_number,  | 
                                                        |
| 289 | - 'R' => $R,  | 
                                                        |
| 290 | - 'Rx_hex' => $Rx_hex,  | 
                                                        |
| 291 | - 'Ry_hex' => $Ry_hex  | 
                                                        |
| 288 | + 'random_number' => $random_number,  | 
                                                        |
| 289 | + 'R' => $R,  | 
                                                        |
| 290 | + 'Rx_hex' => $Rx_hex,  | 
                                                        |
| 291 | + 'Ry_hex' => $Ry_hex  | 
                                                        |
| 292 | 292 | );  | 
                                                        
| 293 | 293 | }  | 
                                                        
| 294 | 294 | |
@@ -65,12 +65,12 @@  | 
                                                    ||
| 65 | 65 | public function __construct($pubkey = '', $type = '02', $version = '0F')  | 
                                                        
| 66 | 66 |      { | 
                                                        
| 67 | 67 | $this->rawHashes = array(  | 
                                                        
| 68 | - 'step1' => null,  | 
                                                        |
| 69 | - 'step2' => null,  | 
                                                        |
| 70 | - 'step3' => null,  | 
                                                        |
| 71 | - 'step4' => null,  | 
                                                        |
| 72 | - 'step5' => null,  | 
                                                        |
| 73 | - 'step6' => null,  | 
                                                        |
| 68 | + 'step1' => null,  | 
                                                        |
| 69 | + 'step2' => null,  | 
                                                        |
| 70 | + 'step3' => null,  | 
                                                        |
| 71 | + 'step4' => null,  | 
                                                        |
| 72 | + 'step5' => null,  | 
                                                        |
| 73 | + 'step6' => null,  | 
                                                        |
| 74 | 74 | );  | 
                                                        
| 75 | 75 | |
| 76 | 76 | $this->encoded = '';  |