diff --git a/src/Utils/Constant.php b/src/Utils/Constant.php index db00ba5ab..2e577b572 100644 --- a/src/Utils/Constant.php +++ b/src/Utils/Constant.php @@ -18,6 +18,7 @@ class Constant 'LYRA' => "44'/497'/0'/0", 'TESTNET' => "44'/1'/0'/0", 'DOGE' => "44'/3'/0'/0", + 'ADA' => "1852'/1815'/0'", ]; public const CONTRACT_ADDRESSES = array( diff --git a/src/Utils/Currency.php b/src/Utils/Currency.php index 3d795289b..c4ddfa96a 100644 --- a/src/Utils/Currency.php +++ b/src/Utils/Currency.php @@ -15,4 +15,5 @@ class Currency extends Enum public const ETH = 'ETH'; public const LTC = 'LTC'; public const DOGE = 'DOGE'; + public const ADA = 'ADA'; } diff --git a/src/Wallet/Ada.php b/src/Wallet/Ada.php new file mode 100644 index 000000000..043d958cd --- /dev/null +++ b/src/Wallet/Ada.php @@ -0,0 +1,29 @@ +mnemonicToEntropy($mnemonic); + } + + public function generateAdaWallet(string $mnemonic) : array + { + $entropy = self::generateEntropyFromMnemonic($mnemonic); + $xprv = hash_pbkdf2('sha512', '', $entropy->getHex(), 4096, 96); + + $xprv[0] &= 248; + $xprv[31] &= 31; + $xprv[31] |= 64; + + } +} \ No newline at end of file diff --git a/src/Wallet/Address.php b/src/Wallet/Address.php deleted file mode 100644 index 66ee54b08..000000000 --- a/src/Wallet/Address.php +++ /dev/null @@ -1,47 +0,0 @@ -entropyToMnemonic($entropy); } + /** + * @param $mnemonic + */ + private function generateEntropyFromMnemonic($mnemonic): \BitWasp\Buffertools\BufferInterface + { + $bip39 = MnemonicFactory::bip39(); + return $bip39->mnemonicToEntropy($mnemonic); + } + /** * @param string $mnemonic * @return \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey @@ -256,6 +265,7 @@ public function generateWallet( case Currency::DOGE: return $this->generateBtcBasedWallet($mnemonic); case Currency::ETH: + case Currency::ADA: return $this->generateEthWallet($mnemonic); default: throw new UnexpectedValueException('Unsupported Blockchain' . $this->currency . '.'); diff --git a/tests/WalletTest.php b/tests/WalletTest.php index e369a64df..8607ec6c5 100644 --- a/tests/WalletTest.php +++ b/tests/WalletTest.php @@ -13,6 +13,8 @@ public function testGenerateWallets() foreach ($currencies as $currency) { $wallet = new Wallet($currency); $generatedWallet = $wallet->generateWallet(); + print_r($generatedWallet); + print_r($currency); self::assertWallet($generatedWallet); } }