@@ -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,13 +124,17 @@ 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))); |
122 | 134 | } |
123 | 135 | |
124 | 136 | /** |
125 | - * @param $data |
|
137 | + * @param string $data |
|
126 | 138 | * @return string |
127 | 139 | */ |
128 | 140 | public function hash160($data) |
@@ -157,6 +169,10 @@ discard block |
||
157 | 169 | * @return String Base58 |
158 | 170 | * @throws \Exception |
159 | 171 | */ |
172 | + |
|
173 | + /** |
|
174 | + * @param string $data |
|
175 | + */ |
|
160 | 176 | public function base58_encode($data, $littleEndian = true) |
161 | 177 | { |
162 | 178 | $res = ''; |
@@ -444,6 +460,10 @@ discard block |
||
444 | 460 | * @return array|null |
445 | 461 | * @throws \Exception |
446 | 462 | */ |
463 | + |
|
464 | + /** |
|
465 | + * @param resource $a |
|
466 | + */ |
|
447 | 467 | public function sqrt($a) |
448 | 468 | { |
449 | 469 | $p = $this->p; |
@@ -483,6 +503,10 @@ discard block |
||
483 | 503 | * @param null $derEvenOrOddCode |
484 | 504 | * @return array|null|String |
485 | 505 | */ |
506 | + |
|
507 | + /** |
|
508 | + * @param string $x |
|
509 | + */ |
|
486 | 510 | public function calculateYWithX($x, $derEvenOrOddCode = null) |
487 | 511 | { |
488 | 512 | $a = $this->a; |
@@ -603,6 +627,11 @@ discard block |
||
603 | 627 | * @param $y |
604 | 628 | * @return bool |
605 | 629 | */ |
630 | + |
|
631 | + /** |
|
632 | + * @param string $x |
|
633 | + * @param string $y |
|
634 | + */ |
|
606 | 635 | public function validatePoint($x, $y) |
607 | 636 | { |
608 | 637 | $a = $this->a; |
@@ -802,6 +831,10 @@ discard block |
||
802 | 831 | * @param String Base58 $address |
803 | 832 | * @return bool |
804 | 833 | */ |
834 | + |
|
835 | + /** |
|
836 | + * @param string $address |
|
837 | + */ |
|
805 | 838 | public function validateAddress($address) |
806 | 839 | { |
807 | 840 | $address = hex2bin($this->base58_decode($address)); |
@@ -822,6 +855,10 @@ discard block |
||
822 | 855 | * @param String Base58 $wif |
823 | 856 | * @return bool |
824 | 857 | */ |
858 | + |
|
859 | + /** |
|
860 | + * @param string $wif |
|
861 | + */ |
|
825 | 862 | public function validateWifKey($wif) |
826 | 863 | { |
827 | 864 | $key = $this->base58_decode($wif, false); |
@@ -914,6 +951,10 @@ discard block |
||
914 | 951 | * @param null $nonce |
915 | 952 | * @return string |
916 | 953 | */ |
954 | + |
|
955 | + /** |
|
956 | + * @param string $hash |
|
957 | + */ |
|
917 | 958 | public function signHash($hash, $nonce = null) |
918 | 959 | { |
919 | 960 | $points = $this->getSignatureHashPoints($hash, $nonce); |
@@ -933,6 +974,10 @@ discard block |
||
933 | 974 | * @return string |
934 | 975 | * @throws \Exception |
935 | 976 | */ |
977 | + |
|
978 | + /** |
|
979 | + * @param string $message |
|
980 | + */ |
|
936 | 981 | public function signMessage($message, $compressed = true, $nonce = null) |
937 | 982 | { |
938 | 983 | |
@@ -1009,6 +1054,12 @@ discard block |
||
1009 | 1054 | * @param $hash |
1010 | 1055 | * @return array |
1011 | 1056 | */ |
1057 | + |
|
1058 | + /** |
|
1059 | + * @param string $R |
|
1060 | + * @param string $S |
|
1061 | + * @param string $hash |
|
1062 | + */ |
|
1012 | 1063 | public function getPubKeyWithRS($flag, $R, $S, $hash) |
1013 | 1064 | { |
1014 | 1065 | |
@@ -1166,6 +1217,12 @@ discard block |
||
1166 | 1217 | * @param $hash |
1167 | 1218 | * @return bool |
1168 | 1219 | */ |
1220 | + |
|
1221 | + /** |
|
1222 | + * @param string $pubKey |
|
1223 | + * @param string $signature |
|
1224 | + * @param string $hash |
|
1225 | + */ |
|
1169 | 1226 | public function checkDerSignature($pubKey, $signature, $hash) |
1170 | 1227 | { |
1171 | 1228 | $signature = hex2bin($signature); |
@@ -1195,6 +1252,10 @@ discard block |
||
1195 | 1252 | * @param $rawMessage |
1196 | 1253 | * @return bool |
1197 | 1254 | */ |
1255 | + |
|
1256 | + /** |
|
1257 | + * @param string $rawMessage |
|
1258 | + */ |
|
1198 | 1259 | public function checkSignatureForRawMessage($rawMessage) |
1199 | 1260 | { |
1200 | 1261 | //recover message. |
@@ -1216,6 +1277,10 @@ discard block |
||
1216 | 1277 | * @param $message |
1217 | 1278 | * @return bool |
1218 | 1279 | */ |
1280 | + |
|
1281 | + /** |
|
1282 | + * @param string $encodedSignature |
|
1283 | + */ |
|
1219 | 1284 | public function checkSignatureForMessage($address, $encodedSignature, $message) |
1220 | 1285 | { |
1221 | 1286 | $hash = $this->hash256("\x18Bitcoin Signed Message:\n" . $this->numToVarIntString(strlen($message)) . $message); |