All Projects → gangan1345 → mnemonic-sdk

gangan1345 / mnemonic-sdk

Licence: Apache-2.0 License
Mnemonic bip39 bip32 bip44 生成助记词 私钥

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to mnemonic-sdk

ethereum-hdwallet
CLI and Node.js library for Ethereum HD Wallet derivations from mnemonic
Stars: ✭ 44 (+76%)
Mutual labels:  wallet, bip44, mnemonic, bip39, bip32
cashuwallet
Cashu is a cryptocurrency wallet for smartphones. Be your own bank. Accept payments or spend crypto directly from your phone.
Stars: ✭ 35 (+40%)
Mutual labels:  wallet, bip44, bip39, bip32
ChainWallet
一个以研究技术为目地的基础项目,也只有最基本 Bitcoin、Ethereum 、EOS 相关的加密算法。
Stars: ✭ 26 (+4%)
Mutual labels:  bip44, mnemonic, bip39, bip32
bitcoincashj
A library for working with Bitcoin Cash
Stars: ✭ 38 (+52%)
Mutual labels:  bip44, bip39, bip32
Multy-IOS
Mobile multy-blockchain wallet client.
Stars: ✭ 25 (+0%)
Mutual labels:  bip44, bip39, bip32
Multy-android
Mobile multy-blockchain wallet client.
Stars: ✭ 17 (-32%)
Mutual labels:  wallet, bip44, bip32
python-hdwallet
Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.
Stars: ✭ 210 (+740%)
Mutual labels:  wallet, bip44, bip32
hd-address
An extensible HD Wallet Address management utility
Stars: ✭ 22 (-12%)
Mutual labels:  wallet, mnemonic
iota-mnemonic
Generate, restore IOTA seed from Bitcoin BIP39 mnemonic
Stars: ✭ 16 (-36%)
Mutual labels:  mnemonic, bip39
Seedshift
Plausibly deniable steganographic encryption of BIP-39 mnemonic seed words with a date shift cipher
Stars: ✭ 21 (-16%)
Mutual labels:  mnemonic, bip39
BIP39
Java Microlibrary implementation of BIP0039
Stars: ✭ 88 (+252%)
Mutual labels:  mnemonic, bip39
wallet-eos
wallet-eos EOS钱包 助记词 私钥 转账
Stars: ✭ 28 (+12%)
Mutual labels:  wallet, mnemonic
python-bip32
Minimalistic implementation of BIP32
Stars: ✭ 28 (+12%)
Mutual labels:  wallet, bip32
Multy-Core
Cross-platform mobile-first library for HD wallets and creating raw transactions of Bitcoin and Ethereum.
Stars: ✭ 23 (-8%)
Mutual labels:  bip44, bip39
btc-address-generator
Bitcoin address generator (bech32, segwit, paper wallets, BIP39 seed, etc.)
Stars: ✭ 80 (+220%)
Mutual labels:  bip39, bip32
go-bip44
A Golang implementation of the BIP44 for Hierarchical Deterministic (HD) addresses.
Stars: ✭ 23 (-8%)
Mutual labels:  bip44, bip32
ed25519-hd-key
🔐 Key Derivation for ed25519
Stars: ✭ 54 (+116%)
Mutual labels:  bip44, bip32
btclib
btclib: a python3 library for 'bitcoin cryptography'
Stars: ✭ 60 (+140%)
Mutual labels:  bip39, bip32
willwallet
以太坊钱包
Stars: ✭ 17 (-32%)
Mutual labels:  wallet, mnemonic
boxwallet
BoxWallet is a single binary multi-coin CLI tool, that gets your coin-of-choice wallet/node set-up fast, with just a few commands.
Stars: ✭ 23 (-8%)
Mutual labels:  wallet

mnemonic-sdk

Mnemonic bip39 bip32 bip44

支持 BIP39 助记词 支持 BIP32 子私钥 支持 BIP44 多币种管理

Install

Gradle:

Add dependency:

dependencies {
    implementation 'com.lgann.develop:mnemonic-sdk:1.0.0'
}

Maven:

<dependency>
  <groupId>com.lgann.develop</groupId>
  <artifactId>mnemonic-sdk</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Usage

生成助记词

// 默认生成12个单词的助记词
String mnemonic = MnemonicUtils.generateMnemonic();
System.out.println("mnemonic = " + mnemonic);

助记词:exchange throw faculty fiction require father prefer mask organ crumble journey cricket

生成种子

// 根据助记词生成种子
byte[] seed = MnemonicUtils.generateSeed(mnemonic, "");
System.out.println("seed = " + Numeric.toHexString(seed));

种子: 0x7eaedb7137ef3c3b9da8c2bd976d639455133ef76be73fda9c8342c922c98ca910fe195a5db88c43fa526b3504569f6aa7476d738a6e11f8feb48aa03ae0eac0

生成一个bip32 私钥

byte[] privateKeyBytes = KeyPairUtils.generatePrivateKey(seed, KeyPairUtils.CoinTypes.EOS);
System.out.println("privateKeyBytes:"+ Numeric.toHexString(privateKeyBytes));

私钥:0x05b04396cf928446dd14be3d58cad3f64ff7b61730462e14a0722caaaf6a1d49

generatePrivateKey具体实现如下
说明:生成的助记词 通过bip32 bip44 转换生成的私钥 可以让同一个 seed 可以支援多币种、多帐户等

// "m/44'/60'/0'/0/0"
// 1. we just need eth wallet for now
AddressIndex addressIndex = BIP44
        .m()
        .purpose44()
        .coinType(coinType)
        .account(0)
        .external()
        .address(0);
// 2. calculate seed from mnemonics , then get master/root key ; 
// Note that the bip39 passphrase we set "" for common
ExtendedPrivateKey rootKey = ExtendedPrivateKey.fromSeed(seed, network);
// 3. get child private key deriving from master/root key
ExtendedPrivateKey childPrivateKey = rootKey.derive(addressIndex, AddressIndex.DERIVATION);
// 4. get key pair
byte[] privateKeyBytes = childPrivateKey.getKey();

如果是ETH钱包开发的话导入了web3j的库 ,可使用ECKeyPair 生成私钥和公钥。
ETH、EOS等账户体系会有所不同,生成私钥和公钥有所区别

// 生成私钥和公钥
ECKeyPair keyPair = ECKeyPair.create(privateKeyBytes);

说明

BIP32:定义 Hierarchical Deterministic wallet (简称 “HD Wallet”),是一个系统可以从单一个 seed 产生一树状结构储存多组 keypairs(私钥和公钥)。好处是可以方便的备份、转移到其他相容装置(因为都只需要 seed),以及分层的权限控制等。
BIP39:将 seed 用方便记忆和书写的单字表示。一般由 12 个单字组成,称为 mnemonic code(phrase),中文称为助记词或助记码。
BIP44:基于 BIP32 的系统,赋予树状结构中的各层特殊的意义。让同一个 seed 可以支援多币种、多帐户等。各层定义如下:

m / purpose' / coin_type' / account' / change / address_index
//purporse': 固定值44', 代表是BIP44
//coin_type': 这个代表的是币种, 可以兼容很多种币, 比如BTC是0', ETH是60'
//btc一般是 m/44'/0'/0'/0
//eth一般是 m/44'/60'/0'/0

如果需要测试助记词, 和校验助记词生成的地址, 那么可以访问这个网站: https://iancoleman.io/bip39/

Bip44 注册币种列表

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].