多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
波场没有找到官方固定的助记词类库 1.助记词 composer require furqansiddiqui/bip39-mnemonic-php ~~~ 三种方式: $mnemonic = BIP39::Generate(12); $mnemonic = BIP39::Entropy("f47f0e5dcf6d1ddf0e70791dafc9ae512130891817769976cd50533021e58a8b"); $mnemonic = BIP39::Words("virtual wear number paddle spike usage degree august buffalo layer high"); var_dump($mnemonic->words); # array(12) { [0]=> string(6) "barrel" [1]=> string(6) "viable" [2]=> string(6) "become" [3]=> string(4) "kiss" [4]=> string(6) "spider" [5]=> string(8) "business" [6]=> string(4) "wool" [7]=> string(6) "amused" [8]=> string(7) "satoshi" [9]=> string(4) "duty" [10]=> string(4) "girl" [11]=> string(5) "april" } var_dump($mnemonic->entropy); # string(32) "12de684fbd6d1a3e3f5041bf68918905" ~~~ 2.私钥 composer require simplito/elliptic-php 第一种根据助记词生成私钥 use Elliptic\EdDSA; $mnemonic = "setup finish syrup atom color awkward file online venue grant toss slice"; $secret = hash_pbkdf2('sha512', $mnemonic, 'mnemonic', 2048); $EdDSA = new EdDSA('ed25519'); $kp = $EdDSA->keyFromSecret($secret); assert($secret == $kp->getSecret('hex')); $getSecret =$kp->getSecret('hex'); $Private=$kp->priv()->toString('hex'); var_dump($Private); 第二种:根据商(Entropy)生成私钥 use Elliptic\EC; $ec=new EC('secp256k1') $key = $ec->genKeyPair(['entropy'=>$entropy]); $priv = $ec->keyFromPrivate($key->priv); $private_key=$priv->getPrivate('hex'); var_dump($private_key); 3.公钥 use Elliptic\EC; $ec=new EC('secp256k1') $priv = $ec->keyFromPrivate("92644f568f24f77d07a004cc61d093f12bd5e7a332c5c0f1fe0a26cd81b12f8f"); $pubKeyHex = $priv->getPublic(false, "hex"); var_dump($pubKeyHex );