diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..366f08d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.git/** +.gradle/** +build/** diff --git a/README.md b/README.md index 23f56a1..6c2641a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,20 @@ A Java implementation of the BIP-0038 Draft: [Passphrase-protected private key]( `BIP38.decrypt(password, encryptedKey)` yields the decrypted get. +## Compiling to runnable JAR (using Linux) + +1. Install gradle + + `sudo apt-get install gradle` + +2. Execute + + `gradle clean jar` + +3. Runnable jar is in build/libs + + `java -jar BIP38.jar` + ## Example Key generation: diff --git a/build.gradle b/build.gradle index 2cd2f7d..d8a7d9b 100644 --- a/build.gradle +++ b/build.gradle @@ -4,34 +4,32 @@ apply plugin: 'application' mainClassName = 'com.fruitcat.bitcoin.BIP38' repositories { - mavenCentral() - maven { - url "http://distribution.bitcoinj.googlecode.com/git/releases/" - } -} - -task fatJar(type: Jar) { - from files(sourceSets.main.output.classesDir) - from {configurations.compile.collect {zipTree(it)}} { - exclude "META-INF/*.SF" - exclude "META-INF/*.DSA" - exclude "META-INF/*.RSA" + mavenCentral() } dependencies { compile 'com.madgag:scprov-jdk15on:1.47.0.3' compile 'com.google.guava:guava:15.0' - compile 'com.google:bitcoinj:0.10.3' - compile 'org.bouncycastle:bcprov-jdk16:1.46' + compile 'org.bitcoinj:bitcoinj-core:0.14.3' + compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1' + compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46' testCompile 'org.testng:testng:6.8.7' } -test { - useTestNG() +jar { + manifest { + attributes 'Main-Class': mainClassName + } + from configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" +} +test { + useTestNG() } manifest { - attributes 'Main-Class': 'com.fruitcat.bitcoin.BIP38' - } -} + attributes 'Main-Class': mainClassName +} \ No newline at end of file diff --git a/src/main/java/com/fruitcat/bitcoin/BIP38.java b/src/main/java/com/fruitcat/bitcoin/BIP38.java index 0515a00..8c72d43 100644 --- a/src/main/java/com/fruitcat/bitcoin/BIP38.java +++ b/src/main/java/com/fruitcat/bitcoin/BIP38.java @@ -21,8 +21,8 @@ package com.fruitcat.bitcoin; -import com.google.bitcoin.core.*; -import com.google.bitcoin.params.MainNetParams; +import org.bitcoinj.core.*; +import org.bitcoinj.params.MainNetParams; import com.lambdaworks.crypto.SCrypt; import org.bouncycastle.asn1.sec.SECNamedCurves; import org.bouncycastle.asn1.x9.X9ECParameters; @@ -300,7 +300,9 @@ public static String decryptEC(String passphrase, byte[] encryptedKey) throws Un BigInteger n = CURVE.getN(); BigInteger pk = new BigInteger(1, passFactor).multiply(new BigInteger(1, factorB)).remainder(n); - ECKey privKey = new ECKey(pk, null); + // Old way, deprecated + // ECKey privKey = new ECKey(pk, null); + ECKey privKey = ECKey.fromPrivate(pk); return privKey.getPrivateKeyEncoded(params).toString(); } diff --git a/src/main/java/com/fruitcat/bitcoin/Utils.java b/src/main/java/com/fruitcat/bitcoin/Utils.java index 60ad289..2ad3031 100644 --- a/src/main/java/com/fruitcat/bitcoin/Utils.java +++ b/src/main/java/com/fruitcat/bitcoin/Utils.java @@ -17,8 +17,8 @@ package com.fruitcat.bitcoin; -import com.google.bitcoin.core.AddressFormatException; -import com.google.bitcoin.core.Base58; +import org.bitcoinj.core.AddressFormatException; +import org.bitcoinj.core.Base58; import org.bouncycastle.math.ec.ECPoint; import javax.crypto.Cipher; diff --git a/src/test/java/com/fruitcat/bitcoin/BIP38Test.java b/src/test/java/com/fruitcat/bitcoin/BIP38Test.java index 917c501..5257ced 100644 --- a/src/test/java/com/fruitcat/bitcoin/BIP38Test.java +++ b/src/test/java/com/fruitcat/bitcoin/BIP38Test.java @@ -1,7 +1,6 @@ package com.fruitcat.bitcoin; -import com.google.bitcoin.core.Base58; -import com.google.bitcoin.params.MainNetParams; +import org.bitcoinj.core.Base58; import org.testng.annotations.Test; import java.util.Arrays;