From c971b2d023f3b8fe132efff9867d38d3fd98a25e Mon Sep 17 00:00:00 2001 From: thoffma Date: Tue, 5 May 2015 20:40:03 +0200 Subject: [PATCH 1/3] Updated README --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 23f56a1..80eb89b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,18 @@ 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 build fatJar` + +3. Runnable jar is in build/libs + ## Example Key generation: From ddc571d984a3023d58fe80e78f71db2988dc6437 Mon Sep 17 00:00:00 2001 From: thoffma Date: Tue, 5 May 2015 20:40:59 +0200 Subject: [PATCH 2/3] Updated README 2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80eb89b..968292e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ A Java implementation of the BIP-0038 Draft: [Passphrase-protected private key]( 1. Install gradle - `sudo apt-get install gradle' + `sudo apt-get install gradle` 2. Execute From 3889f5c83b368fe0442d3e22f7de8e43819b1498 Mon Sep 17 00:00:00 2001 From: Lacksfish Date: Mon, 7 Nov 2016 18:55:50 +0100 Subject: [PATCH 3/3] Added support for bitcoinj 0.14.3, fixing the automated gradle jar build, added basic .gitignore --- .gitignore | 3 ++ README.md | 4 ++- build.gradle | 36 +++++++++---------- src/main/java/com/fruitcat/bitcoin/BIP38.java | 8 +++-- src/main/java/com/fruitcat/bitcoin/Utils.java | 4 +-- .../java/com/fruitcat/bitcoin/BIP38Test.java | 3 +- 6 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 .gitignore 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 968292e..6c2641a 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,12 @@ A Java implementation of the BIP-0038 Draft: [Passphrase-protected private key]( 2. Execute - `gradle clean build fatJar` + `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;