Skip to content

Commit f8c542f

Browse files
authored
Merge pull request #447 from tronprotocol/master
merge the master into develop branch
2 parents 676a278 + 939f517 commit f8c542f

File tree

20 files changed

+933
-910
lines changed

20 files changed

+933
-910
lines changed

build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ task wrapper(type: Wrapper) {
6363
}
6464

6565
dependencies {
66-
testCompile group: 'junit', name: 'junit', version: '4.12'
66+
compile group: 'junit', name: 'junit', version: '4.12'
6767
compile group: 'com.beust', name: 'jcommander', version: '1.72'
6868
//compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
6969
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
@@ -76,15 +76,14 @@ dependencies {
7676
compile group: 'io.grpc', name: 'grpc-stub', version: '1.9.0'
7777

7878
compile group: 'com.googlecode.protobuf-java-format', name: 'protobuf-java-format', version: '1.4'
79-
compile "com.madgag.spongycastle:core:1.58.0.0"
80-
compile "com.madgag.spongycastle:prov:1.58.0.0"
79+
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
8180
compile group: 'com.typesafe', name: 'config', version: '1.3.2'
8281
compile "com.google.code.findbugs:jsr305:3.0.0"
8382
compile "org.springframework.cloud:spring-cloud-starter-consul-discovery:${springCloudConsulVersion}"
8483
compile "org.apache.commons:commons-collections4:4.0"
8584
compile "org.apache.commons:commons-lang3:3.4"
8685
compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3'
87-
compile 'com.alibaba:fastjson:1.2.47'
86+
compile 'com.alibaba:fastjson:1.2.76'
8887

8988
compile group: 'commons-io', name: 'commons-io', version: '2.6'
9089
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'

src/main/java/org/tron/common/crypto/ECKey.java

Lines changed: 88 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,63 @@
1717
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
import lombok.extern.slf4j.Slf4j;
21-
import org.spongycastle.asn1.ASN1InputStream;
22-
import org.spongycastle.asn1.ASN1Integer;
23-
import org.spongycastle.asn1.DLSequence;
24-
import org.spongycastle.asn1.sec.SECNamedCurves;
25-
import org.spongycastle.asn1.x9.X9ECParameters;
26-
import org.spongycastle.asn1.x9.X9IntegerConverter;
27-
import org.spongycastle.crypto.agreement.ECDHBasicAgreement;
28-
import org.spongycastle.crypto.digests.SHA256Digest;
29-
import org.spongycastle.crypto.engines.AESEngine;
30-
import org.spongycastle.crypto.modes.SICBlockCipher;
31-
import org.spongycastle.crypto.params.*;
32-
import org.spongycastle.crypto.signers.ECDSASigner;
33-
import org.spongycastle.crypto.signers.HMacDSAKCalculator;
34-
import org.spongycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
35-
import org.spongycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
36-
import org.spongycastle.jce.spec.ECParameterSpec;
37-
import org.spongycastle.jce.spec.ECPrivateKeySpec;
38-
import org.spongycastle.jce.spec.ECPublicKeySpec;
39-
import org.spongycastle.math.ec.ECAlgorithms;
40-
import org.spongycastle.math.ec.ECCurve;
41-
import org.spongycastle.math.ec.ECPoint;
42-
import org.spongycastle.util.BigIntegers;
43-
import org.spongycastle.util.encoders.Base64;
44-
import org.spongycastle.util.encoders.Hex;
45-
import org.tron.common.crypto.cryptohash.Keccak256;
46-
import org.tron.common.crypto.jce.*;
47-
import org.tron.common.utils.BIUtil;
48-
import org.tron.common.utils.ByteUtil;
49-
import org.tron.common.utils.Hash;
50-
51-
import javax.annotation.Nullable;
52-
import javax.crypto.KeyAgreement;
5320
import java.io.IOException;
5421
import java.io.Serializable;
5522
import java.math.BigInteger;
5623
import java.nio.charset.Charset;
57-
import java.security.*;
24+
import java.security.InvalidKeyException;
25+
import java.security.KeyPair;
26+
import java.security.KeyPairGenerator;
27+
import java.security.PrivateKey;
28+
import java.security.Provider;
29+
import java.security.PublicKey;
30+
import java.security.SecureRandom;
31+
import java.security.Signature;
32+
import java.security.SignatureException;
5833
import java.security.interfaces.ECPrivateKey;
5934
import java.security.interfaces.ECPublicKey;
6035
import java.security.spec.InvalidKeySpecException;
6136
import java.util.Arrays;
37+
import javax.annotation.Nullable;
38+
import javax.crypto.KeyAgreement;
39+
import lombok.extern.slf4j.Slf4j;
40+
import org.bouncycastle.asn1.ASN1InputStream;
41+
import org.bouncycastle.asn1.ASN1Integer;
42+
import org.bouncycastle.asn1.DLSequence;
43+
import org.bouncycastle.asn1.sec.SECNamedCurves;
44+
import org.bouncycastle.asn1.x9.X9ECParameters;
45+
import org.bouncycastle.asn1.x9.X9IntegerConverter;
46+
import org.bouncycastle.crypto.agreement.ECDHBasicAgreement;
47+
import org.bouncycastle.crypto.digests.SHA256Digest;
48+
import org.bouncycastle.crypto.engines.AESEngine;
49+
import org.bouncycastle.crypto.modes.SICBlockCipher;
50+
import org.bouncycastle.crypto.params.ECDomainParameters;
51+
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
52+
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
53+
import org.bouncycastle.crypto.params.KeyParameter;
54+
import org.bouncycastle.crypto.params.ParametersWithIV;
55+
import org.bouncycastle.crypto.signers.ECDSASigner;
56+
import org.bouncycastle.crypto.signers.HMacDSAKCalculator;
57+
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
58+
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
59+
import org.bouncycastle.jce.spec.ECParameterSpec;
60+
import org.bouncycastle.jce.spec.ECPrivateKeySpec;
61+
import org.bouncycastle.jce.spec.ECPublicKeySpec;
62+
import org.bouncycastle.math.ec.ECAlgorithms;
63+
import org.bouncycastle.math.ec.ECCurve;
64+
import org.bouncycastle.math.ec.ECPoint;
65+
import org.bouncycastle.util.BigIntegers;
66+
import org.bouncycastle.util.encoders.Base64;
67+
import org.bouncycastle.util.encoders.Hex;
68+
import org.tron.common.crypto.cryptohash.Keccak256;
69+
import org.tron.common.crypto.jce.ECKeyAgreement;
70+
import org.tron.common.crypto.jce.ECKeyFactory;
71+
import org.tron.common.crypto.jce.ECKeyPairGenerator;
72+
import org.tron.common.crypto.jce.ECSignatureFactory;
73+
import org.tron.common.crypto.jce.TronCastleProvider;
74+
import org.tron.common.utils.BIUtil;
75+
import org.tron.common.utils.ByteUtil;
76+
import org.tron.common.utils.Hash;
6277

6378
@Slf4j(topic = "crypto")
6479
public class ECKey implements Serializable, SignInterface {
@@ -680,30 +695,30 @@ private static void check(boolean test, String message) {
680695
}
681696
}
682697

683-
/**
684-
* Returns a copy of this key, but with the public point represented in uncompressed form.
685-
* Normally you would never need this: it's for specialised scenarios or when backwards
686-
* compatibility in encoded form is necessary.
687-
*
688-
* @return -
689-
* @deprecated per-point compression property will be removed in Bouncy Castle
690-
*/
691-
public ECKey decompress() {
692-
if (!pub.isCompressed()) {
693-
return this;
694-
} else {
695-
return new ECKey(this.provider, this.privKey, decompressPoint(pub));
696-
}
697-
}
698-
699-
/** @deprecated per-point compression property will be removed in Bouncy Castle */
700-
public ECKey compress() {
701-
if (pub.isCompressed()) {
702-
return this;
703-
} else {
704-
return new ECKey(this.provider, this.privKey, compressPoint(pub));
705-
}
706-
}
698+
// /**
699+
// * Returns a copy of this key, but with the public point represented in uncompressed form.
700+
// * Normally you would never need this: it's for specialised scenarios or when backwards
701+
// * compatibility in encoded form is necessary.
702+
// *
703+
// * @return -
704+
// * @deprecated per-point compression property will be removed in Bouncy Castle
705+
// */
706+
// public ECKey decompress() {
707+
// if (!pub.isCompressed()) {
708+
// return this;
709+
// } else {
710+
// return new ECKey(this.provider, this.privKey, decompressPoint(pub));
711+
// }
712+
// }
713+
//
714+
// /** @deprecated per-point compression property will be removed in Bouncy Castle */
715+
// public ECKey compress() {
716+
// if (pub.isCompressed()) {
717+
// return this;
718+
// } else {
719+
// return new ECKey(this.provider, this.privKey, compressPoint(pub));
720+
// }
721+
// }
707722

708723
/**
709724
* Returns true if this key doesn't have access to private key bytes. This may be because it was
@@ -809,21 +824,21 @@ public BigInteger getPrivKey() {
809824
}
810825
}
811826

812-
/**
813-
* Returns whether this key is using the compressed form or not. Compressed pubkeys are only 33
814-
* bytes, not 64.
815-
*
816-
* @return -
817-
*/
818-
public boolean isCompressed() {
819-
return pub.isCompressed();
820-
}
821-
822-
public String toString() {
823-
StringBuilder b = new StringBuilder();
824-
b.append("pub:").append(Hex.toHexString(pub.getEncoded(false)));
825-
return b.toString();
826-
}
827+
// /**
828+
// * Returns whether this key is using the compressed form or not. Compressed pubkeys are only 33
829+
// * bytes, not 64.
830+
// *
831+
// * @return -
832+
// */
833+
// public boolean isCompressed() {
834+
// return pub.isCompressed();
835+
// }
836+
//
837+
// public String toString() {
838+
// StringBuilder b = new StringBuilder();
839+
// b.append("pub:").append(Hex.toHexString(pub.getEncoded(false)));
840+
// return b.toString();
841+
// }
827842

828843
/**
829844
* Produce a string rendering of the ECKey INCLUDING the private key. Unless you absolutely need

0 commit comments

Comments
 (0)