|
17 | 17 | * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 | */ |
19 | 19 |
|
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; |
53 | 20 | import java.io.IOException; |
54 | 21 | import java.io.Serializable; |
55 | 22 | import java.math.BigInteger; |
56 | 23 | 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; |
58 | 33 | import java.security.interfaces.ECPrivateKey; |
59 | 34 | import java.security.interfaces.ECPublicKey; |
60 | 35 | import java.security.spec.InvalidKeySpecException; |
61 | 36 | 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; |
62 | 77 |
|
63 | 78 | @Slf4j(topic = "crypto") |
64 | 79 | public class ECKey implements Serializable, SignInterface { |
@@ -680,30 +695,30 @@ private static void check(boolean test, String message) { |
680 | 695 | } |
681 | 696 | } |
682 | 697 |
|
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 | +// } |
707 | 722 |
|
708 | 723 | /** |
709 | 724 | * 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() { |
809 | 824 | } |
810 | 825 | } |
811 | 826 |
|
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 | +// } |
827 | 842 |
|
828 | 843 | /** |
829 | 844 | * Produce a string rendering of the ECKey INCLUDING the private key. Unless you absolutely need |
|
0 commit comments