Closed keninqiu closed 4 years ago
Could you help me add test to cover this code, Thanks!
import 'package:bip39/bip39.dart' as bip39; import 'package:bip32/bip32.dart' as bip32; import 'package:hex/hex.dart';
test() { const randomMnemonic = 'culture sound obey clean pretty medal churn behind chief cactus alley ready'; var seed = bip39.mnemonicToSeed(randomMnemonic); var root = bip32.BIP32.fromSeed(seed); var child = root.derivePath("m/44'/60'/0'/0/0"); var publicKey = HEX.encode(child.publicKey); print(publicKey); }
You can check it from https://iancoleman.io/bip39/. the publicKey should be 0x020c91d155e52b37d4d7d2c9127501a00a841acd8ef1d7b05f3079120df145da6a But the code shows 02cbdc25dcdde03ac8d2b3cf785d035ae86e99e662c26f99ab8ab6d0e5f3554e86
Thanks @keninqiu. I merged
When do Uint8List dt = toBuffer((dd + tt) % n); It will happened the length of dt is smaller than 32. We have to make sure the length is always 32.