novacrypto / bip39 Goto Github PK
View Code? Open in Web Editor NEWJava Microlibrary implementation of BIP0039
Home Page: https://novacrypto.github.io/BIP39
License: GNU General Public License v3.0
Java Microlibrary implementation of BIP0039
Home Page: https://novacrypto.github.io/BIP39
License: GNU General Public License v3.0
We already do this, if the client has the words chosen from the dictionary and can provide the indexes into the dictionary, it would save client combining, then library normalizing, splitting to a list, and finding the indexes. Plus it would avoid the client handling WordNotFoundException
and UnexpectedWhiteSpaceException
.
As seen in other projects, a search and replace could accidentally modify a word in a word list.
https://github.com/litecoin-foundation/loafwallet-android/issues/33
On Android < 26
Caused by: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA512 implementation not found
at io.github.novacrypto.toruntime.CheckedExceptionToRuntime.toRuntime(CheckedExceptionToRuntime.java:48)
at io.github.novacrypto.bip39.SeedCalculator.getPbkdf2WithHmacSHA512(SeedCalculator.java:91)
at io.github.novacrypto.bip39.SeedCalculator.<init>(SeedCalculator.java:40)
See: https://developer.android.com/reference/javax/crypto/SecretKeyFactory.html
public byte[] calculateSeed(String mnemonic, String passphrase) {
This should be able to take CharSequence
but the normalizer is insisting we have String
input.
May throw word not found, that would actually be found if normalized.
when i use
f=fc534ee49d7d44f7942996f13ba11372f939e5fcc02dd89eb4fdd23e4dcdb134
new MnemonicGenerator(wordList)
.createMnemonic(f, sb::append);
i got "wisdom omit rice depend stairs knock expose crazy van tackle dynamic tourist near very vessel aisle sudden volcano disorder piece tooth traffic shadow mother" total 24 words,
i wannn 12 word. like METAMASK
thank you
What's wrong with this mnemonic generated by Electrum LTC 2.8.3.5:
despair neck garden cabbage one bless help lamp marriage can mushroom moon
https://iancoleman.github.io/bip39/ doesn't like it.
Interested which side of the fence this library falls on.
Currently, only English and Japanese are tested and supported.
Possibly allow a relaxation of this rule option.
I tried the example "Using a StringBuilder" and got "Exception in thread "main" java.lang.NoClassDefFoundError: io/github/novacrypto/hashing/Sha256".
MnemonicGenerator has an import of io.github.novacrypto.hashing.Sha256, but there is no such package as io.github.novacrypto.hashing.
Hello, I am very happy to use your powerful encryption library, but when I was testing the demo example on this page (https://iancoleman.io/bip39/#english), I encountered a problem: From Derived Addresses Title,
In the Table tab , how to generate different addresses, public keys, and private keys according to different Derived Paths. When I use the BIP39 library, I don’t know how to implement it. cloud you give me a java demo? Because the page is implemented through the javascript lib, but how to implement the java BIP39 library, I read all the unit tests and don’t know how to write the code, so I need your help. thanks!
link:
https://github.com/NovaCrypto/BIP39
https://iancoleman.io/bip39/#english
How to get private key in the project?
Starting from May 1, 2021 JCenter will stop working. Can you please publish the library to MavenCentral?
Possible alternatives
JitPack
GitHub Packages
The method for splitting the string and looking up the words can be simplified.
Currently, it causes a word not found ""
exception, which is not very helpful.
JDK1.8.0_121
Intellij IDEA
Without Andriod development environment
class io.github.novacrypto.hashing.Sha256$1 cannot access its superinterface io.github.novacrypto.toruntime.CheckedExceptionToRuntime$Func at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at io.github.novacrypto.hashing.Sha256.sha256(Sha256.java:57) at io.github.novacrypto.hashing.Sha256.sha256(Sha256.java:40) at io.github.novacrypto.hashing.Sha256.sha256(Sha256.java:36) at io.github.novacrypto.bip39.MnemonicGenerator.firstByteOfSha256(MnemonicGenerator.java:120) at io.github.novacrypto.bip39.MnemonicGenerator.wordIndexes(MnemonicGenerator.java:104) at io.github.novacrypto.bip39.MnemonicGenerator.createMnemonic(MnemonicGenerator.java:81)
Quoting BIP 39:
HMAC-SHA512 is used as the pseudo-random function.
Quoting SeedCalculator.java:38:
private final PBKDF2WithHmacSHA256 hashAlgorithm;
public SeedCalculator(PBKDF2WithHmacSHA256 hashAlgorithm) {
this.hashAlgorithm = hashAlgorithm;
}
On a two-minute glance through the code, I had an understandable reaction. Then, I reached for grep
and found these:
JavaxPBKDF2WithHmacSHA256.java:36:
public enum JavaxPBKDF2WithHmacSHA256 implements PBKDF2WithHmacSHA256 {
INSTANCE;
private SecretKeyFactory skf = getPbkdf2WithHmacSHA512();
@Override
public byte[] hash(char[] chars, byte[] salt) {
final PBEKeySpec spec = new PBEKeySpec(chars, salt, 2048, 512);
SpongyCastlePBKDF2WithHmacSHA256.java:32:
public enum SpongyCastlePBKDF2WithHmacSHA256 implements PBKDF2WithHmacSHA256 {
INSTANCE;
@Override
public byte[] hash(char[] chars, byte[] salt) {
PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA512Digest());
I am still not sure how it all fits together. But I suggest it may be kinder to code reviewers to not misidentify the PRF in variable names. Or perhaps you wish to test whether readers be paying attention? [g]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.