public function testMnemonicDecode()
 {
     $mnemonic = trim('teach start paradise collect blade chill gay childhood creek picture creator branch');
     $known_seed = 'dcb85458ec2fcaaac54b71fba90bd4a5';
     $known_secexp = '74b1f6c0caae485b4aeb2f26bab3cabdec4f0b432751bd454fe11b2d2907cbda';
     $known_mpk = '819519e966729f31e1855eb75133d9e7f0c31abaadd8f184870d62771c62c2e759406ace1dee933095d15e4c719617e252f32dc0465393055f867aee9357cd52';
     $known_addresses = ["", "", "", "", ""];
     $seed = Electrum::decode_mnemonic($mnemonic);
     $this->assertEquals($seed, $known_seed);
     $mpk = Electrum::generate_mpk($seed);
     $this->assertEquals($mpk, $known_mpk);
     $secexp = Electrum::stretch_seed($seed);
     $secexp = $secexp['seed'];
     $this->assertEquals($secexp, $known_secexp);
     $count_known_addresses = count($known_addresses);
     for ($i = 0; $i < $count_known_addresses; $i++) {
         $privkey = Electrum::generate_private_key($secexp, $i, 0);
         $address_private_deriv = BitcoinLib::private_key_to_address($privkey, $this->magic_byte);
         $public_deriv = Electrum::public_key_from_mpk($mpk, $i);
         $address_private_deriv = BitcoinLib::public_key_to_address($public_deriv, $this->magic_byte);
     }
 }
<?php

use BitWasp\BitcoinLib\BitcoinLib;
use BitWasp\BitcoinLib\Electrum;
require_once __DIR__ . '/../vendor/autoload.php';
$magic_byte = '00';
$string = trim('teach start paradise collect blade chill gay childhood creek picture creator branch');
$seed = Electrum::decode_mnemonic($string);
echo "Words: {$string}\n";
echo "Seed:  {$seed}\n";
$secexp = Electrum::stretch_seed($seed);
$secexp = $secexp['seed'];
echo "Secret Exponent: {$secexp}\n";
$mpk = Electrum::generate_mpk($seed);
echo "MPK: {$mpk}\n";
for ($i = 0; $i < 5; $i++) {
    $privkey = Electrum::generate_private_key($secexp, $i, 0);
    echo "Private key: {$privkey}\n";
    echo "Private WIF: " . BitcoinLib::private_key_to_WIF($privkey, FALSE, $magic_byte) . "\n";
    $public_key = Electrum::public_key_from_mpk($mpk, $i);
    echo "Public Key: {$public_key}\n";
    $address = BitcoinLib::public_key_to_address($public_key, $magic_byte);
    echo "Public derivation: {$address}.\n";
    $address = BitcoinLib::private_key_to_address($privkey, $magic_byte);
    echo "Private derivation: {$address}.\n";
    echo "-----------\n";
}
                $i++;
            }
            if ($to_check == 0) {
                $json_str = json_encode($try);
            }
        }
    }
}
while (!isset($seed)) {
    echo "\nEnter electrum seed or mnemonic: ";
    $line = trim(fgets(STDIN));
    if (ctype_xdigit($line) and strlen($line) >= 32) {
        $seed = $line;
        continue;
    }
    $decode_mnemonic = Electrum::decode_mnemonic($line);
    if (strlen($decode_mnemonic) > 29) {
        $seed = $decode_mnemonic;
        continue;
    }
    echo "Not a valid seed, or too weak ( < 128 bit)\n\n";
}
echo "Seed accepted.\n\n";
// Learn how many keys we put into the redeem script.
$seed = Electrum::stretch_seed($seed);
$seed = $seed['seed'];
$master_public_key = Electrum::generate_mpk($seed);
$private_keys = array();
$have_keys = 0;
$done = FALSE;
// Loop until the user is satisfied they have found all keys.