22
33namespace AndKom \Bitcoin \Blockchain \Crypto ;
44
5- use AndKom \Bitcoin \Blockchain \Exception \ CryptoException ;
5+ use AndKom \Bitcoin \Blockchain \Exceptions \ PublicKeyException ;
66use AndKom \Bitcoin \Blockchain \Utils ;
77use Mdanter \Ecc \EccFactory ;
88
@@ -57,12 +57,12 @@ public function getX(): \GMP
5757
5858 /**
5959 * @return \GMP
60- * @throws CryptoException
60+ * @throws PublicKeyException
6161 */
6262 public function getY (): \GMP
6363 {
6464 if ($ this ->isCompressed ()) {
65- throw new CryptoException ("Compressed public key doesn't have Y coordinate. " );
65+ throw new PublicKeyException ("Compressed public key doesn't have Y coordinate. " );
6666 }
6767
6868 return $ this ->y ;
@@ -86,12 +86,12 @@ public function isCompressed(): bool
8686
8787 /**
8888 * @return PublicKey
89- * @throws CryptoException
89+ * @throws PublicKeyException
9090 */
9191 public function compress (): self
9292 {
9393 if ($ this ->isCompressed ()) {
94- throw new CryptoException ('Public key is already compressed. ' );
94+ throw new PublicKeyException ('Public key is already compressed. ' );
9595 }
9696
9797 $ wasOdd = gmp_cmp (
@@ -104,12 +104,12 @@ public function compress(): self
104104
105105 /**
106106 * @return PublicKey
107- * @throws CryptoException
107+ * @throws PublicKeyException
108108 */
109109 public function decompress (): self
110110 {
111111 if (!$ this ->isCompressed ()) {
112- throw new CryptoException ('Public key is already decompressed. ' );
112+ throw new PublicKeyException ('Public key is already decompressed. ' );
113113 }
114114
115115 $ curve = EccFactory::getSecgCurves ()->generator256k1 ()->getCurve ();
@@ -120,7 +120,7 @@ public function decompress(): self
120120
121121 /**
122122 * @return \Mdanter\Ecc\Crypto\Key\PublicKey
123- * @throws CryptoException
123+ * @throws PublicKeyException
124124 */
125125 public function getEccPublicKey (): \Mdanter \Ecc \Crypto \Key \PublicKey
126126 {
@@ -142,7 +142,7 @@ public function getEccPublicKey(): \Mdanter\Ecc\Crypto\Key\PublicKey
142142 /**
143143 * @param string $data
144144 * @return PublicKey
145- * @throws CryptoException
145+ * @throws PublicKeyException
146146 */
147147 static public function parse (string $ data ): self
148148 {
@@ -152,7 +152,7 @@ static public function parse(string $data): self
152152 $ prefix = $ data [0 ];
153153
154154 if ($ prefix != static ::PREFIX_COMPRESSED_ODD && $ prefix != static ::PREFIX_COMPRESSED_EVEN ) {
155- throw new CryptoException ('Invalid compressed public key prefix. ' );
155+ throw new PublicKeyException ('Invalid compressed public key prefix. ' );
156156 }
157157
158158 $ x = Utils::binToGmp (substr ($ data , 1 , 32 ));
@@ -161,13 +161,13 @@ static public function parse(string $data): self
161161 $ prefix = $ data [0 ];
162162
163163 if ($ prefix != static ::PREFIX_UNCOMPRESSED ) {
164- throw new CryptoException ('Invalid uncompressed public key prefix. ' );
164+ throw new PublicKeyException ('Invalid uncompressed public key prefix. ' );
165165 }
166166
167167 $ x = Utils::binToGmp (substr ($ data , 1 , 32 ));
168168 $ y = Utils::binToGmp (substr ($ data , 33 , 32 ));
169169 } else {
170- throw new CryptoException ('Invalid public key size. ' );
170+ throw new PublicKeyException ('Invalid public key size. ' );
171171 }
172172
173173 return new static ($ x , $ y , $ prefix == static ::PREFIX_COMPRESSED_ODD );
0 commit comments