/** EOS https://github.com/espritblock/eos4j
* seedPrivate
*
* @param seed
* @return
*/
public static String seedPrivate(String seed) {
if (seed == null || seed.length() == 0) {
throw new EException("args_empty", "args is empty");
}
byte[] a = { (byte) 0x80 };
byte[] b = new BigInteger(Sha.SHA256(seed)).toByteArray();
byte[] private_key = ByteUtils.concat(a, b);
byte[] checksum = Sha.SHA256(private_key);
checksum = Sha.SHA256(checksum);
byte[] check = ByteUtils.copy(checksum, 0, 4);
byte[] pk = ByteUtils.concat(private_key, check);
return Base58.encode(pk);
}
//ETH https://github.com/web3j/web3j
public static String seedPrivate(String mnemonic) {
byte[] seed = MnemonicUtils.generateSeed(mnemonic,PASSPHRASE);
ECKeyPair keypair = ECKeyPair.create(sha256(seed));
return keypair.getPrivateKey().toString(16);
}
//BTC https://github.com/Samourai-Wallet/samourai-wallet-android
public HD_Wallet(int purpose, MnemonicCode mc, NetworkParameters params, byte[] seed, String passphrase, int nbAccounts) throws MnemonicException.MnemonicLengthException {
mParams = params;
mSeed = seed;
strPassphrase = passphrase;
mWordList = mc.toMnemonic(mSeed);
byte[] hd_seed = MnemonicCode.toSeed(mWordList, strPassphrase);
mKey = HDKeyDerivation.createMasterPrivateKey(hd_seed);
DeterministicKey t1 = HDKeyDerivation.deriveChildKey(mKey, purpose| ChildNumber.HARDENED_BIT);
mRoot = HDKeyDerivation.deriveChildKey(t1, ChildNumber.HARDENED_BIT);
mAccounts = new ArrayList<HD_Account>();
for(int i = 0; i < nbAccounts; i++) {
String acctName = String.format("account %02d", i);
mAccounts.add(new HD_Account(mParams, mRoot, acctName, i));
}
}
助记词生成EOS ETH BTC 钱包 关键代码
猜你喜欢
转载自blog.csdn.net/yujunlong3919/article/details/84562578
今日推荐
周排行