@@ -279,7 +279,7 @@ |
||
279 | 279 | |
280 | 280 | list($remain, $last) = array(bcdiv(bcsub($dec, $last), '16'), bcmod($dec, '16')); |
281 | 281 | |
282 | - return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain) . dechex($last); |
|
282 | + return ($remain == 0) ? dechex($last) : $this->convertDecToHex($remain).dechex($last); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | do { |
130 | 130 | /* Get the message hash and a new random number */ |
131 | - $e = $this->decodeHex('0x' . hash('sha256', $message)); |
|
131 | + $e = $this->decodeHex('0x'.hash('sha256', $message)); |
|
132 | 132 | $k = $this->SecureRandomNumber(); |
133 | 133 | |
134 | 134 | /* Calculate a new curve point from R=k*G (x1,y1) */ |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function Verify($sig, $msg, $pubkey) |
174 | 174 | { |
175 | 175 | if (true === empty($sig) || true === empty($msg) || true === empty($pubkey)) { |
176 | - throw new \Exception('The signature, public key and message parameters are required to verify a signature. Value received for first parameter was "' . var_export($sig, true) . '", second parameter was "' . var_export($msg, true) . '" and third parameter was "' . var_export($pubkey, true) . '".'); |
|
176 | + throw new \Exception('The signature, public key and message parameters are required to verify a signature. Value received for first parameter was "'.var_export($sig, true).'", second parameter was "'.var_export($msg, true).'" and third parameter was "'.var_export($pubkey, true).'".'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $e = ''; |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | $s = $this->binConv($this->CoordinateCheck($s)); |
247 | 247 | |
248 | 248 | $retval = array( |
249 | - 'bin_r' => $this->msbCheck($r[0]) . $r, |
|
250 | - 'bin_s' => $this->msbCheck($s[0]) . $s |
|
249 | + 'bin_r' => $this->msbCheck($r[0]).$r, |
|
250 | + 'bin_s' => $this->msbCheck($s[0]).$s |
|
251 | 251 | ); |
252 | 252 | |
253 | - $seq = chr(0x02) . chr(strlen($retval['bin_r'])) . $retval['bin_r'] . |
|
254 | - chr(0x02) . chr(strlen($retval['bin_s'])) . $retval['bin_s']; |
|
253 | + $seq = chr(0x02).chr(strlen($retval['bin_r'])).$retval['bin_r']. |
|
254 | + chr(0x02).chr(strlen($retval['bin_s'])).$retval['bin_s']; |
|
255 | 255 | |
256 | - return bin2hex(chr(0x30) . chr(strlen($seq)) . $seq); |
|
256 | + return bin2hex(chr(0x30).chr(strlen($seq)).$seq); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | private function ecdsaSigTotalLenCheck($value) |
346 | 346 | { |
347 | 347 | if ($value != '140' && $value != '142' && $value != '144') { |
348 | - throw new \Exception('Invalid ECDSA signature provided! Length is out of range for a correct signature. Value checked was "' . var_export($value, true) . '".'); |
|
348 | + throw new \Exception('Invalid ECDSA signature provided! Length is out of range for a correct signature. Value checked was "'.var_export($value, true).'".'); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | private function derRecordStartCheck($value) |
359 | 359 | { |
360 | 360 | if ($value != '30') { |
361 | - throw new \Exception('Invalid ECDSA signature provided! Unknown signature format. Value checked was "' . var_export($value, true) . '".'); |
|
361 | + throw new \Exception('Invalid ECDSA signature provided! Unknown signature format. Value checked was "'.var_export($value, true).'".'); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | private function derRecordTotalLenCheck($value) |
372 | 372 | { |
373 | 373 | if ($value != '44' && $value != '45' && $value != '46') { |
374 | - throw new \Exception('Invalid ECDSA signature provided! DER record length is invalid. Value checked was "' . var_export($value, true) . '".'); |
|
374 | + throw new \Exception('Invalid ECDSA signature provided! DER record length is invalid. Value checked was "'.var_export($value, true).'".'); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | private function derDataTypeCheck($value) |
385 | 385 | { |
386 | 386 | if ($value != '02') { |
387 | - throw new \Exception('Invalid ECDSA signature provided! DER record length is invalid. Value checked was "' . var_export($value, true) . '".'); |
|
387 | + throw new \Exception('Invalid ECDSA signature provided! DER record length is invalid. Value checked was "'.var_export($value, true).'".'); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | private function derDataLenCheck($value) |
398 | 398 | { |
399 | 399 | if ($value != '20' && $value != '21') { |
400 | - throw new \Exception('Invalid ECDSA signature provided! The coordinate length is invalid. Value checked was "' . var_export($value, true) . '".'); |
|
400 | + throw new \Exception('Invalid ECDSA signature provided! The coordinate length is invalid. Value checked was "'.var_export($value, true).'".'); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | /* |
330 | 330 | * 2. Add a 0x80 byte in front of it for mainnet addresses or 0xef for testnet addresses. |
331 | 331 | */ |
332 | - $step2 = ($network == 'main') ? '80' . $step1 : 'ef' . $step1; |
|
332 | + $step2 = ($network == 'main') ? '80'.$step1 : 'ef'.$step1; |
|
333 | 333 | |
334 | 334 | /* |
335 | 335 | * 3. Append a 0x01 byte after it if it should be used with compressed public keys. Nothing is appended |
336 | 336 | * if it is used with uncompressed public keys. |
337 | 337 | */ |
338 | - $step3 = ($public_key_format == 'compressed') ? $step2 . '01' : $step2; |
|
338 | + $step3 = ($public_key_format == 'compressed') ? $step2.'01' : $step2; |
|
339 | 339 | |
340 | 340 | /* |
341 | 341 | * 4. Perform a SHA-256 hash on the extended key. |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | /* |
356 | 356 | * 7. Add the four checksum bytes from step 6 at the end of the extended key from step 3. |
357 | 357 | */ |
358 | - $step7 = $step3 . $this->checksum; |
|
358 | + $step7 = $step3.$this->checksum; |
|
359 | 359 | |
360 | 360 | /* |
361 | 361 | * 8. Convert the result from a byte string into a Base58 string using Base58Check encoding. |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $private_key_type = substr($private_key, 0, 2); |
390 | 390 | |
391 | 391 | if ($private_key_type != '80' && $private_key_type != 'ef') { |
392 | - throw new \Exception('Invalid WIF encoded private key! Network type was not present in value provided. Checked ' . $private_key . ' and found ' . $private_key_type); |
|
392 | + throw new \Exception('Invalid WIF encoded private key! Network type was not present in value provided. Checked '.$private_key.' and found '.$private_key_type); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | $private_key = substr($private_key, 2); |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | $private_key = ($compressed_public_key == '01') ? substr($private_key, 0, -2) : $private_key; |
398 | 398 | |
399 | 399 | /* Now let's check our private key against the checksum provided. */ |
400 | - $new_checksum = substr(hash('sha256', hash('sha256', $this->binConv($private_key_type . $private_key . $compressed_public_key), true)), 0, 8); |
|
400 | + $new_checksum = substr(hash('sha256', hash('sha256', $this->binConv($private_key_type.$private_key.$compressed_public_key), true)), 0, 8); |
|
401 | 401 | |
402 | 402 | if ($new_checksum != $checksum_provided) { |
403 | - throw new \Exception('Invalid WIF encoded private key! Checksum is incorrect! Value encoded with key was: ' . $checksum_provided . ' but this does not match the recalculated value of: ' . $new_checksum . ' from the decoded provided value of: ' . $decoded_key); |
|
403 | + throw new \Exception('Invalid WIF encoded private key! Checksum is incorrect! Value encoded with key was: '.$checksum_provided.' but this does not match the recalculated value of: '.$new_checksum.' from the decoded provided value of: '.$decoded_key); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | return $private_key; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->rawHashes['step2'] = hash('ripemd160', $this->rawHashes['step1']); |
131 | 131 | |
132 | 132 | /* prepend the hex SINversion and hex SINtype to the hex form of the ripemd160 hash */ |
133 | - $this->rawHashes['step3'] = $this->SINversion . $this->SINtype . $this->rawHashes['step2']; |
|
133 | + $this->rawHashes['step3'] = $this->SINversion.$this->SINtype.$this->rawHashes['step2']; |
|
134 | 134 | |
135 | 135 | /* |
136 | 136 | * convert the appended hex string back to binary and double sha256 hash it leaving |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $this->rawHashes['step5'] = substr(bin2hex($this->rawHashes['step4']), 0, 8); |
143 | 143 | |
144 | 144 | /* append the first 4 bytes to the fully appended string in step 3 */ |
145 | - $this->rawHashes['step6'] = $this->rawHashes['step3'] . $this->rawHashes['step5']; |
|
145 | + $this->rawHashes['step6'] = $this->rawHashes['step3'].$this->rawHashes['step5']; |
|
146 | 146 | |
147 | 147 | /* finally base58 encode it */ |
148 | 148 | $this->encoded = $this->encodeBase58($this->rawHashes['step6']); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return true; |
189 | 189 | } |
190 | 190 | |
191 | - throw new \Exception('Point test failed! Cannot continue. I tested the point: ' . var_export($P, true) . ' but got the point: ' . var_export($test_point, true)); |
|
191 | + throw new \Exception('Point test failed! Cannot continue. I tested the point: '.var_export($P, true).' but got the point: '.var_export($test_point, true)); |
|
192 | 192 | |
193 | 193 | } catch (\Exception $e) { |
194 | 194 | // TODO: Do something useful here... |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $Rx_hex = str_pad($this->encodeHex($R['x']), 64, "0", STR_PAD_LEFT); |
280 | 280 | $Ry_hex = str_pad($this->encodeHex($R['y']), 64, "0", STR_PAD_LEFT); |
281 | 281 | } else { |
282 | - throw new \Exception('Point test failed! Cannot continue. I got the point: ' . var_export($R, true)); |
|
282 | + throw new \Exception('Point test failed! Cannot continue. I got the point: '.var_export($R, true)); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return array( |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | $params = $params ?? []; |
53 | 53 | |
54 | 54 | $this->keyInfo = array( |
55 | - 'private_key_hex' => $this->keyValueCheck($params['private_key_hex'] ?? null), |
|
56 | - 'private_key_dec' => $this->keyValueCheck($params['private_key_dec'] ?? null), |
|
57 | - 'public_key' => $this->keyValueCheck($params['public_key'] ?? null), |
|
55 | + 'private_key_hex' => $this->keyValueCheck($params['private_key_hex'] ?? null), |
|
56 | + 'private_key_dec' => $this->keyValueCheck($params['private_key_dec'] ?? null), |
|
57 | + 'public_key' => $this->keyValueCheck($params['public_key'] ?? null), |
|
58 | 58 | 'public_key_compressed' => $this->keyValueCheck($params['public_key_compressed'] ?? null), |
59 | - 'public_key_x' => $this->keyValueCheck($params['public_key_x'] ?? null), |
|
60 | - 'public_key_y' => $this->keyValueCheck($params['public_key_y'] ?? null), |
|
59 | + 'public_key_x' => $this->keyValueCheck($params['public_key_x'] ?? null), |
|
60 | + 'public_key_y' => $this->keyValueCheck($params['public_key_y'] ?? null), |
|
61 | 61 | 'generation_time' => '', |
62 | 62 | ); |
63 | 63 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | $this->keyInfo = array( |
123 | 123 | 'private_key_hex' => $this->encodeHex($point['random_number']), |
124 | 124 | 'private_key_dec' => $point['random_number'], |
125 | - 'public_key' => '04' . $point['Rx_hex'] . $point['Ry_hex'], |
|
126 | - 'public_key_compressed' => $comp_prefix . $point['Rx_hex'], |
|
125 | + 'public_key' => '04'.$point['Rx_hex'].$point['Ry_hex'], |
|
126 | + 'public_key_compressed' => $comp_prefix.$point['Rx_hex'], |
|
127 | 127 | 'public_key_x' => $point['Rx_hex'], |
128 | 128 | 'public_key_y' => $point['Ry_hex'], |
129 | 129 | ); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $pointX = substr($pubkey, 2); |
161 | 161 | $pointY = substr($this->calcYfromX($pointX, $prefix), 2); |
162 | 162 | |
163 | - $parsedValue = $this->prepAndClean($pointX . $pointY); |
|
163 | + $parsedValue = $this->prepAndClean($pointX.$pointY); |
|
164 | 164 | |
165 | 165 | return ($returnHex === false) ? $parsedValue : $this->encodeHex($parsedValue); |
166 | 166 | } |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | 'a1_ele_len' => '44', |
63 | 63 | 'bit_str_beg' => '03', |
64 | 64 | 'bit_str_len' => '42', |
65 | - 'bit_str_val' => '00' . $keypair[1], |
|
65 | + 'bit_str_val' => '00'.$keypair[1], |
|
66 | 66 | ); |
67 | 67 | |
68 | 68 | $dec = trim(implode($ecpemstruct)); |
69 | 69 | |
70 | 70 | $this->pemDataLenCheck($dec); |
71 | 71 | |
72 | - return '-----BEGIN EC PRIVATE KEY-----' . "\r\n" . chunk_split(base64_encode($this->binConv($dec)), 64) . '-----END EC PRIVATE KEY-----'; |
|
72 | + return '-----BEGIN EC PRIVATE KEY-----'."\r\n".chunk_split(base64_encode($this->binConv($dec)), 64).'-----END EC PRIVATE KEY-----'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->pemOidCheck($ecpemstruct['obj_id_val']); |
95 | 95 | |
96 | 96 | $private_key = $ecpemstruct['oct_sec_val']; |
97 | - $public_key = '04' . $ecpemstruct['bit_str_val']; |
|
97 | + $public_key = '04'.$ecpemstruct['bit_str_val']; |
|
98 | 98 | |
99 | 99 | $this->pemKeyLenCheck(array($private_key, $public_key)); |
100 | 100 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $oid_string = ''; |
220 | 220 | |
221 | 221 | foreach ($oid as $key => $value) { |
222 | - $oid_string .= $value . "."; |
|
222 | + $oid_string .= $value."."; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | $oid_string = substr($oid_string, 0, -1); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $return = strrev($this->encodeValue($hex, '58')); |
321 | 321 | |
322 | 322 | for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == '00'; $i += 2) { |
323 | - $return = '1' . $return; |
|
323 | + $return = '1'.$return; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $return; |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | $return = $this->encodeHex($return); |
357 | 357 | |
358 | 358 | for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) { |
359 | - $return = '00' . $return; |
|
359 | + $return = '00'.$return; |
|
360 | 360 | } |
361 | 361 | |
362 | - return (strlen($return) % 2 != 0) ? '0' . $return : $return; |
|
362 | + return (strlen($return) % 2 != 0) ? '0'.$return : $return; |
|
363 | 363 | |
364 | 364 | } catch (\Exception $e) { |
365 | 365 | // TODO: Need to do something useful here instead of re-throwing the exception. |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | foreach ($params as $key => $value) { |
402 | 402 | if ($this->numberCheck($value) === false) { |
403 | 403 | $caller = debug_backtrace(); |
404 | - throw new \Exception('Empty or invalid parameters passed to ' . $caller[count($caller) - 1]['function'] . ' function.'); |
|
404 | + throw new \Exception('Empty or invalid parameters passed to '.$caller[count($caller) - 1]['function'].' function.'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $qq = $this->math->div($val, $base); |
429 | 429 | $rem = $this->math->mod($val, $base); |
430 | 430 | $val = $qq; |
431 | - $new = $new . $digits[$rem]; |
|
431 | + $new = $new.$digits[$rem]; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $new; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $secure_random_number = ''; |
184 | 184 | |
185 | 185 | while (strlen($secure_random_number) < 78) { |
186 | - $secure_random_number = $secure_random_number . hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))); |
|
186 | + $secure_random_number = $secure_random_number.hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | if ($secure_random_number === false || $cstrong === false) { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | private function addHexPrefix($hex) |
218 | 218 | { |
219 | - return (substr($hex, 0, 2) != '0x') ? '0x' . $hex : $hex; |
|
219 | + return (substr($hex, 0, 2) != '0x') ? '0x'.$hex : $hex; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |