@@ -43,6 +43,10 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | * @throws \Exception |
45 | 45 | */ |
46 | + |
|
47 | + /** |
|
48 | + * @param integer $i |
|
49 | + */ |
|
46 | 50 | public function numToVarIntString($i) { |
47 | 51 | if ($i < 0xfd) { |
48 | 52 | return chr($i); |
@@ -82,6 +86,10 @@ discard block |
||
82 | 86 | * @param bool $reverse |
83 | 87 | * @return null |
84 | 88 | */ |
89 | + |
|
90 | + /** |
|
91 | + * @param string $char |
|
92 | + */ |
|
85 | 93 | public function base58_permutation($char, $reverse = false) |
86 | 94 | { |
87 | 95 | $table = array('1','2','3','4','5','6','7','8','9','A','B','C','D', |
@@ -116,6 +124,10 @@ discard block |
||
116 | 124 | * @param $data |
117 | 125 | * @return string |
118 | 126 | */ |
127 | + |
|
128 | + /** |
|
129 | + * @param string $data |
|
130 | + */ |
|
119 | 131 | public function hash256($data) |
120 | 132 | { |
121 | 133 | return hash('sha256', hex2bin(hash('sha256', $data))); |
@@ -129,6 +141,10 @@ discard block |
||
129 | 141 | * @return String Base58 |
130 | 142 | * @throws \Exception |
131 | 143 | */ |
144 | + |
|
145 | + /** |
|
146 | + * @param string $data |
|
147 | + */ |
|
132 | 148 | public function base58_encode($data, $littleEndian = true) |
133 | 149 | { |
134 | 150 | $res = ''; |
@@ -418,6 +434,10 @@ discard block |
||
418 | 434 | * @return array|null |
419 | 435 | * @throws \Exception |
420 | 436 | */ |
437 | + |
|
438 | + /** |
|
439 | + * @param resource $a |
|
440 | + */ |
|
421 | 441 | public function sqrt($a) |
422 | 442 | { |
423 | 443 | $p = $this->p; |
@@ -457,6 +477,10 @@ discard block |
||
457 | 477 | * @param null $derEvenOrOddCode |
458 | 478 | * @return array|null|String |
459 | 479 | */ |
480 | + |
|
481 | + /** |
|
482 | + * @param string $x |
|
483 | + */ |
|
460 | 484 | public function calculateYWithX($x, $derEvenOrOddCode = null) |
461 | 485 | { |
462 | 486 | $a = $this->a; |
@@ -577,6 +601,11 @@ discard block |
||
577 | 601 | * @param $y |
578 | 602 | * @return bool |
579 | 603 | */ |
604 | + |
|
605 | + /** |
|
606 | + * @param string $x |
|
607 | + * @param string $y |
|
608 | + */ |
|
580 | 609 | public function validatePoint($x, $y) |
581 | 610 | { |
582 | 611 | $a = $this->a; |
@@ -777,6 +806,10 @@ discard block |
||
777 | 806 | * @param String Base58 $address |
778 | 807 | * @return bool |
779 | 808 | */ |
809 | + |
|
810 | + /** |
|
811 | + * @param string $address |
|
812 | + */ |
|
780 | 813 | public function validateAddress($address) |
781 | 814 | { |
782 | 815 | $address = hex2bin($this->base58_decode($address)); |
@@ -799,6 +832,10 @@ discard block |
||
799 | 832 | * @param String Base58 $wif |
800 | 833 | * @return bool |
801 | 834 | */ |
835 | + |
|
836 | + /** |
|
837 | + * @param string $wif |
|
838 | + */ |
|
802 | 839 | public function validateWifKey($wif) |
803 | 840 | { |
804 | 841 | $key = $this->base58_decode($wif, false); |
@@ -889,6 +926,10 @@ discard block |
||
889 | 926 | * @param null $nonce |
890 | 927 | * @return string |
891 | 928 | */ |
929 | + |
|
930 | + /** |
|
931 | + * @param string $hash |
|
932 | + */ |
|
892 | 933 | public function signHash($hash, $nonce = null) |
893 | 934 | { |
894 | 935 | $points = $this->getSignatureHashPoints($hash, $nonce); |
@@ -908,6 +949,10 @@ discard block |
||
908 | 949 | * @return string |
909 | 950 | * @throws \Exception |
910 | 951 | */ |
952 | + |
|
953 | + /** |
|
954 | + * @param string $message |
|
955 | + */ |
|
911 | 956 | public function signMessage($message, $compressed = true, $nonce = null) |
912 | 957 | { |
913 | 958 | |
@@ -984,6 +1029,12 @@ discard block |
||
984 | 1029 | * @param $hash |
985 | 1030 | * @return array |
986 | 1031 | */ |
1032 | + |
|
1033 | + /** |
|
1034 | + * @param string $R |
|
1035 | + * @param string $S |
|
1036 | + * @param string $hash |
|
1037 | + */ |
|
987 | 1038 | public function getPubKeyWithRS($flag, $R, $S, $hash) |
988 | 1039 | { |
989 | 1040 | |
@@ -1141,6 +1192,12 @@ discard block |
||
1141 | 1192 | * @param $hash |
1142 | 1193 | * @return bool |
1143 | 1194 | */ |
1195 | + |
|
1196 | + /** |
|
1197 | + * @param string $pubKey |
|
1198 | + * @param string $signature |
|
1199 | + * @param string $hash |
|
1200 | + */ |
|
1144 | 1201 | public function checkDerSignature($pubKey, $signature, $hash) |
1145 | 1202 | { |
1146 | 1203 | $signature = hex2bin($signature); |
@@ -1170,6 +1227,10 @@ discard block |
||
1170 | 1227 | * @param $rawMessage |
1171 | 1228 | * @return bool |
1172 | 1229 | */ |
1230 | + |
|
1231 | + /** |
|
1232 | + * @param string $rawMessage |
|
1233 | + */ |
|
1173 | 1234 | public function checkSignatureForRawMessage($rawMessage) |
1174 | 1235 | { |
1175 | 1236 | //recover message. |
@@ -1191,6 +1252,10 @@ discard block |
||
1191 | 1252 | * @param $message |
1192 | 1253 | * @return bool |
1193 | 1254 | */ |
1255 | + |
|
1256 | + /** |
|
1257 | + * @param string $encodedSignature |
|
1258 | + */ |
|
1194 | 1259 | public function checkSignatureForMessage($address, $encodedSignature, $message) |
1195 | 1260 | { |
1196 | 1261 | $hash = $this->hash256("\x18Bitcoin Signed Message:\n" . $this->numToVarIntString(strlen($message)) . $message); |