From 9beecb5339a4a66721684f1620487023af29049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BC=D0=B8=D0=BB=D1=8C=20=D0=9C=D1=83=D1=85?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Sun, 8 Jul 2018 10:15:10 +0300 Subject: [PATCH] remove unusable methods; --- src/BIP/Library/KeyPair.php | 78 ------------------------------------- 1 file changed, 78 deletions(-) diff --git a/src/BIP/Library/KeyPair.php b/src/BIP/Library/KeyPair.php index 22015ab..d18ccc4 100644 --- a/src/BIP/Library/KeyPair.php +++ b/src/BIP/Library/KeyPair.php @@ -39,82 +39,4 @@ public function privateKeyTweakAdd(string $privateKey, string $tweak, string $en return $bn; } - - /* - public function publicKeyTweakAdd(string $publicKey, string $tweak, string $enc) - { - $pair = $this->loadPublicKey($publicKey); - if ($pair === null) { - throw new \Exception('Public key parse failed'); - } - - $tweak = new BN($tweak, $enc); - if ($tweak->cmp($this->ec->n) >= 0) { - throw new \Exception('Public key tweak add failed'); - } - - //$this->ec->g->mul($tweak)->add($pair->pub); - } - - protected function loadPublicKey(string $publicKey) - { - $first = substr($publicKey, 0, 2); - - if (in_array($first, ['02', '03']) && strlen($publicKey) === 66) { - return $this->loadCompressedPublicKey($first, substr($publicKey, -64), 'hex'); - } - - if (in_array($first, ['04', '06', '07']) && strlen($publicKey) === 130) { - return $this->loadUncompressedPublicKey($first, substr($publicKey, 2, 66), substr($publicKey, 66, 130), 'hex'); - } - - return null; - } - - protected function loadUncompressedPublicKey(string $first, string $x, string $y, string $enc) - { - $x = new BN($x, $enc); - $y = new BN($y, $enc); - - // overflow - if ($x->cmp($this->ec->p) >= 0 || $y->cmp($this->ec->p) >= 0) { - return null; - } - - $x = $x->toRed($this->ec->red); - $y = $y->toRed($this->ec->red); - - // is odd flag - if (($first === '06' || $first === '07') && $y->isOdd() !== ($first === '07')) { - return null; - } - - // x*x*x + b = y*y - $x3 = $x->redSqr()->redIMul($x); - if (!$y->redSqr()->redISub($x3->redIAdd($this->ec->b))->isZero()) { - return null; - } - - //return - } - - protected function loadCompressedPublicKey(string $first, string $x, string $enc) - { - $x = new BN($x, $enc); - - // overflow - if ($x->cmp($this->ec->p) >= 0) { - return null; - } - $x = $x->toRed($this->ec->red); - - // compute corresponding Y - $y = $x->redSqr()->redIMul($x)->redIAdd($this->ec->b)->redSqrt(); - if (($first === '03') !== $y->isOdd()) { - $y = $y->redNeg(); - } - - //return - } - */ }