Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ if (project.hasProperty("signing.keyId")) {
}

dependencies {
compile group: 'org.bitcoinj', name: 'bitcoinj-core', version: '0.14.7'
compile group: 'com.madgag.spongycastle', name: 'core', version: '1.54.0.0'
compile group: 'org.bitcoinj', name: 'bitcoinj-core', version: '0.15.2'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.62'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile 'com.google.guava:guava:28.0-jre'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.arkecosystem.crypto.encoding.Base58;
import org.arkecosystem.crypto.encoding.Hex;
import org.bitcoinj.core.ECKey;
import org.spongycastle.crypto.digests.RIPEMD160Digest;
import org.bouncycastle.crypto.digests.RIPEMD160Digest;

public class Address {
public static String fromPassphrase(String passphrase, Integer networkVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.arkecosystem.crypto.identities.PrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.SignatureDecodeException;

import java.lang.reflect.Type;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -66,7 +67,11 @@ public boolean verify() {
byte[] signature = Hex.decode(this.signature);
byte[] bytes = toBytes();

return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey());
try {
return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey());
} catch (SignatureDecodeException e) {
return false;
}
}

public boolean secondVerify(String secondPublicKey) {
Expand All @@ -75,7 +80,11 @@ public boolean secondVerify(String secondPublicKey) {
byte[] signature = Hex.decode(this.signSignature);
byte[] bytes = toBytes(false);

return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey());
try {
return ECKey.verify(Sha256Hash.hash(bytes), signature, keys.getPubKey());
} catch (SignatureDecodeException e) {
return false;
}
}

public Transaction parseSignatures(String serialized, int startOffset) {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/arkecosystem/crypto/utils/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.arkecosystem.crypto.identities.PrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.SignatureDecodeException;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -34,7 +35,11 @@ public boolean verify() {
byte[] signature = Hex.decode(this.signature);
byte[] messageBytes = Sha256Hash.hash(this.message.getBytes());

return ECKey.verify(messageBytes, signature, keys.getPubKey());
try {
return ECKey.verify(messageBytes, signature, keys.getPubKey());
} catch (SignatureDecodeException e) {
return false;
}
}

public Map toMap() {
Expand Down