From 047eecf054158039d43633ee6ca4ffbe1bcca59d Mon Sep 17 00:00:00 2001 From: huanghaiquan Date: Sun, 14 Apr 2019 12:26:28 +0800 Subject: [PATCH] Rename some of the types in crypto framework for more accurate expression. --- .../BftsmartConsensusClientFactory.java | 4 +-- .../consensus/client/ClientFactory.java | 4 +-- .../mq/client/MsgQueueClientFactory.java | 4 +-- .../classic/AESEncryptionFunction.java | 2 +- .../classic/ECDSASignatureFunction.java | 4 +-- .../classic/ED25519SignatureFunction.java | 6 ++-- .../service/classic/RSACryptoFunction.java | 4 +-- .../classic/ED25519SignatureFunctionTest.java | 22 +++++++-------- .../crypto/AsymmetricEncryptionFunction.java | 2 +- ...ptoKeyPair.java => AsymmetricKeypair.java} | 10 +++++-- .../crypto/AsymmetricKeypairGenerator.java | 10 +++++++ .../crypto/CryptoKeyPairGenerator.java | 10 ------- .../crypto/CryptoSymmetricKeyGenerator.java | 9 ------ .../blockchain/crypto/SignatureFunction.java | 2 +- .../crypto/SymmetricEncryptionFunction.java | 2 +- .../jd/blockchain/crypto/SymmetricKey.java | 2 +- .../crypto/SymmetricKeyGenerator.java | 9 ++++++ .../crypto/service/sm/SM2CryptoFunction.java | 6 ++-- .../service/sm/SM4EncryptionFunction.java | 2 +- .../service/sm/SM2CyptoFunctionTest.java | 28 +++++++++---------- .../gateway/GatewayServerBooter.java | 6 ++-- .../jd/blockchain/gateway/PeerConnector.java | 4 +-- .../service/PeerConnectionManager.java | 8 +++--- .../blockchain/ledger/LedgerEditerTest.java | 8 +++--- .../blockchain/ledger/LedgerManagerTest.java | 10 +++---- .../jd/blockchain/ledger/LedgerTestUtils.java | 6 ++-- .../ledger/BlockchainKeyGenerator.java | 4 +-- .../blockchain/ledger/BlockchainKeyPair.java | 4 +-- .../ledger/PreparedTransaction.java | 4 +-- .../ledger/TransactionRequestBuilder.java | 6 ++-- .../jd/blockchain/ledger/data/PreparedTx.java | 4 +-- .../ledger/data/TxRequestBuilder.java | 8 +++--- .../ContractCodeDeployOpTemplateTest.java | 2 +- .../DataAccountRegisterOpTemplateTest.java | 2 +- .../ledger/data/DigitalSignatureBlobTest.java | 4 +-- .../ledger/data/ED25519SignatureTest.java | 4 +-- .../ledger/data/TxRequestMessageTest.java | 10 +++---- .../data/UserRegisterOpTemplateTest.java | 4 +-- .../sdk/service/NodeSigningAppender.java | 6 ++-- .../service/PeerBlockchainServiceFactory.java | 8 +++--- .../sdk/samples/SDKDemo_Contract.java | 8 +++--- .../sdk/samples/SDKDemo_DataAccount.java | 8 +++--- .../sdk/samples/SDKDemo_InsertData.java | 8 +++--- .../sdk/samples/SDKDemo_RegisterAccount.java | 4 +-- .../sdk/samples/SDKDemo_RegisterTest.java | 2 +- .../sdk/samples/SDKDemo_RegisterUser.java | 4 +-- .../blockchain/sdk/samples/SDKDemo_User.java | 10 +++---- .../SDK_GateWay_BatchInsertData_Test_.java | 8 +++--- .../test/SDK_GateWay_DataAccount_Test_.java | 8 +++--- .../test/SDK_GateWay_InsertData_Test_.java | 8 +++--- .../sdk/test/SDK_GateWay_Query_Test_.java | 4 +-- .../sdk/test/SDK_GateWay_User_Test_.java | 8 +++--- .../blockchain/intgr/IntegratedContext.java | 8 +++--- .../jd/blockchain/intgr/IntegrationTest.java | 28 +++++++++---------- .../intgr/consensus/ConsensusTest.java | 12 ++++---- .../intgr/perf/GlobalPerformanceTest.java | 12 ++++---- .../intgr/perf/LedgerInitializeTest.java | 10 +++---- .../intgr/perf/LedgerPerformanceTest.java | 16 +++++------ .../com/jd/blockchain/intgr/perf/Utils.java | 10 +++---- .../jd/blockchain/intgr/IntegrationBase.java | 12 ++++---- .../blockchain/intgr/IntegrationBaseTest.java | 10 +++---- .../jd/blockchain/intgr/IntegrationTest2.java | 16 +++++------ .../intgr/IntegrationTest4Bftsmart.java | 4 +-- .../blockchain/intgr/IntegrationTest4MQ.java | 4 +-- .../intgr/IntegrationTestAll4Redis.java | 22 +++++++-------- .../intgr/IntegrationTestDataAccount.java | 16 +++++------ .../batch/bftsmart/BftsmartLedgerInit.java | 4 +-- .../batch/bftsmart/BftsmartTestBase.java | 4 +-- .../initializer/LedgerInitializeTest.java | 10 +++---- .../ledger/LedgerBlockGeneratingTest.java | 6 ++-- .../service/RemoteTransactionService.java | 10 +++---- .../capability/service/SettingsInit.java | 4 +-- .../settings/CapabilitySettings.java | 4 +-- .../tools/keygen/KeyGenCommand.java | 4 +-- 74 files changed, 283 insertions(+), 277 deletions(-) rename source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/{CryptoKeyPair.java => AsymmetricKeypair.java} (74%) create mode 100644 source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java delete mode 100644 source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java delete mode 100644 source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java create mode 100644 source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java diff --git a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java index 3104adfb..dc3592b6 100644 --- a/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java +++ b/source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java @@ -10,7 +10,7 @@ import com.jd.blockchain.consensus.bftsmart.BftsmartClientIncomingSettings; import com.jd.blockchain.consensus.client.ClientFactory; import com.jd.blockchain.consensus.client.ClientSettings; import com.jd.blockchain.consensus.client.ConsensusClient; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -32,7 +32,7 @@ public class BftsmartConsensusClientFactory implements ClientFactory { @Override - public BftsmartClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) { + public BftsmartClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) { PubKey pubKey = clientKeyPair.getPubKey(); PrivKey privKey = clientKeyPair.getPrivKey(); diff --git a/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java b/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java index 82d2fd94..57fc2dd3 100644 --- a/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java +++ b/source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java @@ -3,7 +3,7 @@ package com.jd.blockchain.consensus.client; import com.jd.blockchain.consensus.ClientIdentification; import com.jd.blockchain.consensus.ClientIncomingSettings; import com.jd.blockchain.consensus.ConsensusManageService; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; public interface ClientFactory { @@ -13,7 +13,7 @@ public interface ClientFactory { * @param clientKeyPair * @return */ - ClientIdentification buildAuthId(CryptoKeyPair clientKeyPair); + ClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair); /** * 根据接入配置信息创建客户端的本地连接配置; diff --git a/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java b/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java index 5c809adc..57729f20 100644 --- a/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java +++ b/source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java @@ -16,7 +16,7 @@ import com.jd.blockchain.consensus.mq.config.MsgQueueClientConfig; import com.jd.blockchain.consensus.mq.settings.MsgQueueClientIncomingSettings; import com.jd.blockchain.consensus.mq.settings.MsgQueueClientSettings; import com.jd.blockchain.consensus.mq.settings.MsgQueueConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -32,7 +32,7 @@ import com.jd.blockchain.crypto.SignatureFunction; public class MsgQueueClientFactory implements ClientFactory { @Override - public MsgQueueClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) { + public MsgQueueClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) { PubKey pubKey = clientKeyPair.getPubKey(); byte[] address = pubKey.toBytes(); // 使用公钥地址作为认证信息 diff --git a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java index d6e42764..3903e5eb 100644 --- a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java +++ b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java @@ -221,7 +221,7 @@ public class AESEncryptionFunction implements SymmetricEncryptionFunction { } @Override - public CryptoKey generateSymmetricKey() { + public SymmetricKey generateSymmetricKey() { // 根据对应的标识和原始密钥生成相应的密钥数据 return new SymmetricKey(AES, AESUtils.generateKey128_Bytes()); } diff --git a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java index 779d77a6..478c7733 100644 --- a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java +++ b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java @@ -1,7 +1,7 @@ package com.jd.blockchain.crypto.service.classic; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -63,7 +63,7 @@ public class ECDSASignatureFunction implements SignatureFunction { } @Override - public CryptoKeyPair generateKeyPair() { + public AsymmetricKeypair generateKeypair() { return null; } } diff --git a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java index ff1d5dfb..e4ae762d 100644 --- a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java +++ b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java @@ -7,7 +7,7 @@ import static com.jd.blockchain.crypto.CryptoKeyType.PUBLIC; import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoException; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -154,7 +154,7 @@ public class ED25519SignatureFunction implements SignatureFunction { } @Override - public CryptoKeyPair generateKeyPair() { + public AsymmetricKeypair generateKeypair() { // 调用ED25519算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 AsymmetricCipherKeyPair keyPair = ED25519Utils.generateKeyPair(); Ed25519PrivateKeyParameters privKeyParams = (Ed25519PrivateKeyParameters) keyPair.getPrivate(); @@ -167,7 +167,7 @@ public class ED25519SignatureFunction implements SignatureFunction { // EdDSAPrivateKey privKey = (EdDSAPrivateKey) keyPair.getPrivate(); // EdDSAPublicKey pubKey = (EdDSAPublicKey) keyPair.getPublic(); // return new CryptoKeyPair(new PubKey(ED25519, pubKey.getAbyte()), new PrivKey(ED25519, privKey.getSeed())); - return new CryptoKeyPair(new PubKey(ED25519, pubKeyBytes), new PrivKey(ED25519, privKeyBytes)); + return new AsymmetricKeypair(new PubKey(ED25519, pubKeyBytes), new PrivKey(ED25519, privKeyBytes)); } } diff --git a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java index 3e14f981..e37c6d35 100644 --- a/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java +++ b/source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java @@ -4,7 +4,7 @@ import com.jd.blockchain.crypto.AsymmetricCiphertext; import com.jd.blockchain.crypto.AsymmetricEncryptionFunction; import com.jd.blockchain.crypto.Ciphertext; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -88,7 +88,7 @@ public class RSACryptoFunction implements AsymmetricEncryptionFunction, Signatur } @Override - public CryptoKeyPair generateKeyPair() { + public AsymmetricKeypair generateKeypair() { return null; } } diff --git a/source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java b/source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java index 7c2bfdbe..08313ada 100644 --- a/source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java +++ b/source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoException; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -64,7 +64,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -97,7 +97,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -122,7 +122,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); SignatureDigest signatureDigest = signatureFunction.sign(privKey,data); @@ -150,7 +150,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -168,7 +168,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); byte[] privKeyBytes = privKey.toBytes(); @@ -193,7 +193,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); byte[] privKeyBytes = privKey.toBytes(); @@ -233,7 +233,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); byte[] pubKeyBytes = pubKey.toBytes(); @@ -258,7 +258,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); byte[] pubKeyBytes = pubKey.toBytes(); @@ -304,7 +304,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); @@ -335,7 +335,7 @@ public class ED25519SignatureFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java index 71cca1ba..fef57412 100644 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java @@ -1,6 +1,6 @@ package com.jd.blockchain.crypto; -public interface AsymmetricEncryptionFunction extends CryptoKeyPairGenerator, CryptoFunction { +public interface AsymmetricEncryptionFunction extends AsymmetricKeypairGenerator, CryptoFunction { /** * 加密; diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPair.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypair.java similarity index 74% rename from source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPair.java rename to source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypair.java index 283d217b..7a454021 100644 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPair.java +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypair.java @@ -1,6 +1,12 @@ package com.jd.blockchain.crypto; -public class CryptoKeyPair { +/** + * 非对称密钥对; + * + * @author huanghaiquan + * + */ +public class AsymmetricKeypair { private PubKey pubKey; @@ -18,7 +24,7 @@ public class CryptoKeyPair { return privKey; } - public CryptoKeyPair(PubKey pubKey, PrivKey privKey) { + public AsymmetricKeypair(PubKey pubKey, PrivKey privKey) { if (pubKey.getAlgorithm() != privKey.getAlgorithm()) { throw new IllegalArgumentException("The algorithms of PubKey and PrivKey don't match!"); } diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java new file mode 100644 index 00000000..964ec048 --- /dev/null +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java @@ -0,0 +1,10 @@ +package com.jd.blockchain.crypto; + +public interface AsymmetricKeypairGenerator { + + /** + * 返回密钥对; + */ + AsymmetricKeypair generateKeypair(); + +} diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java deleted file mode 100644 index 9139548f..00000000 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.jd.blockchain.crypto; - -public interface CryptoKeyPairGenerator { - - /** - * 返回密钥对; - */ - CryptoKeyPair generateKeyPair(); - -} diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java deleted file mode 100644 index baafb599..00000000 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jd.blockchain.crypto; - -public interface CryptoSymmetricKeyGenerator { - - /** - * 返回对称密钥; - */ - CryptoKey generateSymmetricKey(); -} diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java index d1b3b241..f1978424 100644 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java @@ -1,6 +1,6 @@ package com.jd.blockchain.crypto; -public interface SignatureFunction extends CryptoKeyPairGenerator, CryptoFunction { +public interface SignatureFunction extends AsymmetricKeypairGenerator, CryptoFunction { /** * 计算指定数据的 hash; diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java index cb48c99b..4ae72162 100644 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java @@ -3,7 +3,7 @@ package com.jd.blockchain.crypto; import java.io.InputStream; import java.io.OutputStream; -public interface SymmetricEncryptionFunction extends CryptoSymmetricKeyGenerator, CryptoFunction { +public interface SymmetricEncryptionFunction extends SymmetricKeyGenerator, CryptoFunction { /** * 加密; diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java index f335b8ae..84ffd898 100644 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java @@ -3,7 +3,7 @@ package com.jd.blockchain.crypto; import static com.jd.blockchain.crypto.CryptoKeyType.SYMMETRIC; /** - * 单密钥; + * 对称密钥; * * @author huanghaiquan * diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java new file mode 100644 index 00000000..727df9ff --- /dev/null +++ b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java @@ -0,0 +1,9 @@ +package com.jd.blockchain.crypto; + +public interface SymmetricKeyGenerator { + + /** + * 返回对称密钥; + */ + SymmetricKey generateSymmetricKey(); +} diff --git a/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java b/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java index 531c4801..8d5cba8a 100644 --- a/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java +++ b/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java @@ -14,7 +14,7 @@ import com.jd.blockchain.crypto.AsymmetricEncryptionFunction; import com.jd.blockchain.crypto.Ciphertext; import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoException; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -210,7 +210,7 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur } @Override - public CryptoKeyPair generateKeyPair() { + public AsymmetricKeypair generateKeypair() { // 调用SM2算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair(); @@ -230,6 +230,6 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur byte[] pubKeyBytes = ecPub.getQ().getEncoded(false); - return new CryptoKeyPair(new PubKey(SM2, pubKeyBytes), new PrivKey(SM2, privKeyBytes)); + return new AsymmetricKeypair(new PubKey(SM2, pubKeyBytes), new PrivKey(SM2, privKeyBytes)); } } diff --git a/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java b/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java index 31932649..892b21f8 100644 --- a/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java +++ b/source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java @@ -205,7 +205,7 @@ public class SM4EncryptionFunction implements SymmetricEncryptionFunction { } @Override - public CryptoKey generateSymmetricKey() { + public SymmetricKey generateSymmetricKey() { // 根据对应的标识和原始密钥生成相应的密钥数据 return new SymmetricKey(SM4, SM4Utils.generateKey()); } diff --git a/source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java b/source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java index 74221938..33214dc5 100644 --- a/source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java +++ b/source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java @@ -49,7 +49,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -82,7 +82,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -107,7 +107,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); SignatureDigest signatureDigest = signatureFunction.sign(privKey, data); @@ -137,7 +137,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -159,7 +159,7 @@ public class SM2CyptoFunctionTest { AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders .getAsymmetricEncryptionFunction(algorithm); - CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); + AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); @@ -190,7 +190,7 @@ public class SM2CyptoFunctionTest { AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders .getAsymmetricEncryptionFunction(algorithm); - CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); + AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); PrivKey privKey = keyPair.getPrivKey(); @@ -210,7 +210,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); byte[] privKeyBytes = privKey.toBytes(); @@ -235,7 +235,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); byte[] privKeyBytes = privKey.toBytes(); @@ -275,7 +275,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); byte[] pubKeyBytes = pubKey.toBytes(); @@ -300,7 +300,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); byte[] pubKeyBytes = pubKey.toBytes(); @@ -344,7 +344,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); @@ -374,7 +374,7 @@ public class SM2CyptoFunctionTest { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); - CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); PrivKey privKey = keyPair.getPrivKey(); @@ -420,7 +420,7 @@ public class SM2CyptoFunctionTest { AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders .getAsymmetricEncryptionFunction(algorithm); - CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); + AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); @@ -452,7 +452,7 @@ public class SM2CyptoFunctionTest { AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders .getAsymmetricEncryptionFunction(algorithm); - CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); + AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); PubKey pubKey = keyPair.getPubKey(); diff --git a/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java b/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java index f2fb855b..3b9604f3 100644 --- a/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java +++ b/source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java @@ -11,7 +11,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.ClassPathResource; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.tools.keygen.KeyGenCommand; @@ -80,7 +80,7 @@ public class GatewayServerBooter { private volatile ConfigurableApplicationContext appCtx; private GatewayConfigProperties config; - private CryptoKeyPair defaultKeyPair; + private AsymmetricKeypair defaultKeyPair; private String springConfigLocation; public GatewayServerBooter(GatewayConfigProperties config, String springConfigLocation) { this.config = config; @@ -102,7 +102,7 @@ public class GatewayServerBooter { } else { privKey = KeyGenCommand.decodePrivKey(base58PrivKey, base58Pwd); } - defaultKeyPair = new CryptoKeyPair(pubKey, privKey); + defaultKeyPair = new AsymmetricKeypair(pubKey, privKey); } public synchronized void start() { diff --git a/source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java b/source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java index 6a643123..fafeff1e 100644 --- a/source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java +++ b/source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java @@ -1,6 +1,6 @@ package com.jd.blockchain.gateway; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.utils.net.NetworkAddress; import java.util.List; @@ -11,7 +11,7 @@ public interface PeerConnector { boolean isConnected(); - void connect(NetworkAddress peerAddress, CryptoKeyPair defaultKeyPair, List peerProviders); + void connect(NetworkAddress peerAddress, AsymmetricKeypair defaultKeyPair, List peerProviders); void reconnect(); diff --git a/source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java b/source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java index 92a7151a..443b1208 100644 --- a/source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java +++ b/source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java @@ -4,7 +4,7 @@ import javax.annotation.PreDestroy; import org.springframework.stereotype.Component; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.gateway.PeerConnector; import com.jd.blockchain.gateway.PeerService; import com.jd.blockchain.ledger.data.TransactionService; @@ -21,7 +21,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { private volatile NetworkAddress peerAddress; - private volatile CryptoKeyPair gateWayKeyPair; + private volatile AsymmetricKeypair gateWayKeyPair; private volatile List peerProviders; @@ -36,7 +36,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { } @Override - public synchronized void connect(NetworkAddress peerAddress, CryptoKeyPair defaultKeyPair, List peerProviders) { + public synchronized void connect(NetworkAddress peerAddress, AsymmetricKeypair defaultKeyPair, List peerProviders) { if (isConnected()) { if (this.peerAddress.equals(peerAddress)) { return; @@ -98,7 +98,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { this.peerAddress = peerAddress; } - public void setGateWayKeyPair(CryptoKeyPair gateWayKeyPair) { + public void setGateWayKeyPair(AsymmetricKeypair gateWayKeyPair) { this.gateWayKeyPair = gateWayKeyPair; } diff --git a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java index 583b1169..0cd38b02 100644 --- a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java +++ b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.service.classic.ClassicCryptoService; @@ -57,7 +57,7 @@ public class LedgerEditerTest { LedgerTransactionContext txCtx = ldgEdt.newTransaction(genesisTxReq); LedgerDataSet ldgDS = txCtx.getDataSet(); - CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); @Test public void testWriteDataAccoutKvOp() { @@ -121,7 +121,7 @@ public class LedgerEditerTest { parties[0] = new ConsensusParticipantData(); parties[0].setId(0); parties[0].setName("John"); - CryptoKeyPair kp0 = signFunc.generateKeyPair(); + AsymmetricKeypair kp0 = signFunc.generateKeypair(); parties[0].setPubKey(kp0.getPubKey()); parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); parties[0].setHostAddress(new NetworkAddress("192.168.1.6", 9000)); @@ -129,7 +129,7 @@ public class LedgerEditerTest { parties[1] = new ConsensusParticipantData(); parties[1].setId(1); parties[1].setName("John"); - CryptoKeyPair kp1 = signFunc.generateKeyPair(); + AsymmetricKeypair kp1 = signFunc.generateKeypair(); parties[1].setPubKey(kp1.getPubKey()); parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); parties[1].setHostAddress(new NetworkAddress("192.168.1.7", 9000)); diff --git a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java index 78ddef97..4e206204 100644 --- a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java +++ b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -182,7 +182,7 @@ public class LedgerManagerTest { parties[0] = new ConsensusParticipantData(); parties[0].setId(0); parties[0].setName("John"); - CryptoKeyPair kp0 = signatureFunction.generateKeyPair(); + AsymmetricKeypair kp0 = signatureFunction.generateKeypair(); parties[0].setPubKey(kp0.getPubKey()); parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); parties[0].setHostAddress(new NetworkAddress("127.0.0.1", 9000)); @@ -190,7 +190,7 @@ public class LedgerManagerTest { parties[1] = new ConsensusParticipantData(); parties[1].setId(1); parties[1].setName("Mary"); - CryptoKeyPair kp1 = signatureFunction.generateKeyPair(); + AsymmetricKeypair kp1 = signatureFunction.generateKeypair(); parties[1].setPubKey(kp1.getPubKey()); parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); parties[1].setHostAddress(new NetworkAddress("127.0.0.1", 9010)); @@ -198,7 +198,7 @@ public class LedgerManagerTest { parties[2] = new ConsensusParticipantData(); parties[2].setId(2); parties[2].setName("Jerry"); - CryptoKeyPair kp2 = signatureFunction.generateKeyPair(); + AsymmetricKeypair kp2 = signatureFunction.generateKeypair(); parties[2].setPubKey(kp2.getPubKey()); parties[2].setAddress(AddressEncoding.generateAddress(kp2.getPubKey()).toBase58()); parties[2].setHostAddress(new NetworkAddress("127.0.0.1", 9020)); @@ -206,7 +206,7 @@ public class LedgerManagerTest { parties[3] = new ConsensusParticipantData(); parties[3].setId(3); parties[3].setName("Tom"); - CryptoKeyPair kp3 = signatureFunction.generateKeyPair(); + AsymmetricKeypair kp3 = signatureFunction.generateKeypair(); parties[3].setPubKey(kp3.getPubKey()); parties[3].setAddress(AddressEncoding.generateAddress(kp3.getPubKey()).toBase58()); parties[3].setHostAddress(new NetworkAddress("127.0.0.1", 9030)); diff --git a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java index befce4d8..4c3842b4 100644 --- a/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java +++ b/source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java @@ -2,7 +2,7 @@ package test.com.jd.blockchain.ledger; import java.util.Random; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PubKey; @@ -34,7 +34,7 @@ public class LedgerTestUtils { TxTemplate txTemp = new TxTemplate(ledgerHash, txHandle); - CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); PubKey pubKey = cryptoKeyPair.getPubKey(); txTemp.users().register(new BlockchainIdentityData(pubKey)); PreparedTransaction ptx = txTemp.prepare(); @@ -51,7 +51,7 @@ public class LedgerTestUtils { txTemp.contractEvents().send(contractAddress, event, args); - CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); PubKey pubKey = cryptoKeyPair.getPubKey(); txTemp.users().register(new BlockchainIdentityData(pubKey)); PreparedTransaction ptx = txTemp.prepare(); diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java index 7957cdfd..86288f08 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java @@ -1,7 +1,7 @@ package com.jd.blockchain.ledger; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.SignatureFunction; @@ -33,7 +33,7 @@ public class BlockchainKeyGenerator { public BlockchainKeyPair generate(CryptoAlgorithm signatureAlgorithm) { SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction(signatureAlgorithm); - CryptoKeyPair cryptoKeyPair = signFunc.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair(); return new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); } diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java index 705ecfba..53bb3bc8 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java @@ -1,6 +1,6 @@ package com.jd.blockchain.ledger; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.utils.Bytes; @@ -11,7 +11,7 @@ import com.jd.blockchain.utils.Bytes; * @author huanghaiquan * */ -public class BlockchainKeyPair extends CryptoKeyPair { +public class BlockchainKeyPair extends AsymmetricKeypair { private BlockchainIdentity id; diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java index 850a7fd8..d73d6091 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java @@ -1,6 +1,6 @@ package com.jd.blockchain.ledger; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -39,7 +39,7 @@ public interface PreparedTransaction extends HashObject { * 签名账户的私钥; * @return */ - DigitalSignature sign(CryptoKeyPair keyPair); + DigitalSignature sign(AsymmetricKeypair keyPair); /** * 加入签名; diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java index 356bcbbf..0818d865 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java @@ -1,6 +1,6 @@ package com.jd.blockchain.ledger; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; /** @@ -38,7 +38,7 @@ public interface TransactionRequestBuilder extends HashObject { * 签名账户的私钥; * @return */ - DigitalSignature signAsEndpoint(CryptoKeyPair keyPair); + DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair); /** * 对交易进行签名; @@ -49,7 +49,7 @@ public interface TransactionRequestBuilder extends HashObject { * 签名账户的私钥; * @return */ - DigitalSignature signAsNode(CryptoKeyPair keyPair); + DigitalSignature signAsNode(AsymmetricKeypair keyPair); /** * 加入签名; diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java index c66d9ae2..9068405c 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java @@ -1,7 +1,7 @@ package com.jd.blockchain.ledger.data; import com.jd.blockchain.binaryproto.BinaryEncodingUtils; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -36,7 +36,7 @@ public class PreparedTx implements PreparedTransaction { } @Override - public DigitalSignature sign(CryptoKeyPair keyPair) { + public DigitalSignature sign(AsymmetricKeypair keyPair) { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(keyPair.getAlgorithm()); PrivKey privKey = keyPair.getPrivKey(); byte[] content = BinaryEncodingUtils.encode(getTransactionContent(), TransactionContent.class); diff --git a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java index 77185341..0c639b4d 100644 --- a/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java +++ b/source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.jd.blockchain.binaryproto.BinaryEncodingUtils; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -41,14 +41,14 @@ public class TxRequestBuilder implements TransactionRequestBuilder { } @Override - public DigitalSignature signAsEndpoint(CryptoKeyPair keyPair) { + public DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair) { DigitalSignature signature = sign(txContent, keyPair); addEndpointSignature(signature); return signature; } @Override - public DigitalSignature signAsNode(CryptoKeyPair keyPair) { + public DigitalSignature signAsNode(AsymmetricKeypair keyPair) { DigitalSignature signature = sign(txContent, keyPair); addNodeSignature(signature); return signature; @@ -64,7 +64,7 @@ public class TxRequestBuilder implements TransactionRequestBuilder { endpointSignatures.add(signature); } - public static DigitalSignature sign(TransactionContent txContent, CryptoKeyPair keyPair) { + public static DigitalSignature sign(TransactionContent txContent, AsymmetricKeypair keyPair) { SignatureDigest signatureDigest = sign(txContent, keyPair.getPrivKey()); DigitalSignature signature = new DigitalSignatureBlob(keyPair.getPubKey(), signatureDigest); return signature; diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java index c363b17e..97f59d9e 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java @@ -43,7 +43,7 @@ public class ContractCodeDeployOpTemplateTest { DataContractRegistry.register(ContractCodeDeployOperation.class); DataContractRegistry.register(Operation.class); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); - PubKey pubKey = signFunc.generateKeyPair().getPubKey(); + PubKey pubKey = signFunc.generateKeypair().getPubKey(); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); byte[] chainCode = "jd-test".getBytes(); data = new ContractCodeDeployOpTemplate(contractID, chainCode); diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java index 4c26d192..d8fd0695 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java @@ -40,7 +40,7 @@ public class DataAccountRegisterOpTemplateTest { DataContractRegistry.register(DataAccountRegisterOperation.class); DataContractRegistry.register(Operation.class); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); - PubKey pubKey = signFunc.generateKeyPair().getPubKey(); + PubKey pubKey = signFunc.generateKeypair().getPubKey(); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); data = new DataAccountRegisterOpTemplate(contractID); diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java index e5eee356..52629988 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -41,7 +41,7 @@ public class DigitalSignatureBlobTest { DataContractRegistry.register(DigitalSignature.class); DataContractRegistry.register(DigitalSignatureBody.class); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); - CryptoKeyPair kp = signFunc.generateKeyPair(); + AsymmetricKeypair kp = signFunc.generateKeypair(); PubKey pubKey = kp.getPubKey(); SignatureDigest digest = signFunc.sign(kp.getPrivKey(), "zhangsan".getBytes()); diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java index db64c3ad..ff6d42f1 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java @@ -4,7 +4,7 @@ import java.util.Random; import org.junit.Test; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.utils.security.Ed25519Utils; @@ -18,7 +18,7 @@ public class ED25519SignatureTest { rand.nextBytes(data); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); - CryptoKeyPair key = signFunc.generateKeyPair(); + AsymmetricKeypair key = signFunc.generateKeypair(); byte[] pubKey = key.getPubKey().getRawKeyBytes(); byte[] privKey = key.getPrivKey().getRawKeyBytes(); diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java index bfc9a53a..e71f7644 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -60,10 +60,10 @@ public class TxRequestMessageTest { data = new TxRequestMessage(initTransactionContent()); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); - CryptoKeyPair key1 = signFunc.generateKeyPair(); - CryptoKeyPair key2 = signFunc.generateKeyPair(); - CryptoKeyPair key3 = signFunc.generateKeyPair(); - CryptoKeyPair key4 = signFunc.generateKeyPair(); + AsymmetricKeypair key1 = signFunc.generateKeypair(); + AsymmetricKeypair key2 = signFunc.generateKeypair(); + AsymmetricKeypair key3 = signFunc.generateKeypair(); + AsymmetricKeypair key4 = signFunc.generateKeypair(); SignatureDigest digest1 = signFunc.sign(key1.getPrivKey(), "zhangsan".getBytes()); SignatureDigest digest2 = signFunc.sign(key2.getPrivKey(), "lisi".getBytes()); diff --git a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java index e16f0a91..b231842e 100644 --- a/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java +++ b/source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java @@ -15,7 +15,7 @@ import org.junit.Test; import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.ledger.BlockchainIdentity; @@ -39,7 +39,7 @@ public class UserRegisterOpTemplateTest { public void initUserRegisterOpTemplate() { DataContractRegistry.register(UserRegisterOperation.class); DataContractRegistry.register(Operation.class); - CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); + AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); PubKey pubKey = key.getPubKey(); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); data = new UserRegisterOpTemplate(contractID); diff --git a/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java b/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java index 1b202ed7..58d26d4e 100644 --- a/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java +++ b/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java @@ -5,7 +5,7 @@ import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.consensus.MessageService; import com.jd.blockchain.consensus.client.ConsensusClient; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -37,11 +37,11 @@ public class NodeSigningAppender implements TransactionService { private ConsensusClient consensusClient; - private CryptoKeyPair nodeKeyPair; + private AsymmetricKeypair nodeKeyPair; private CryptoAlgorithm hashAlgorithm; - public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, CryptoKeyPair nodeKeyPair, ConsensusClient consensusClient) { + public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, AsymmetricKeypair nodeKeyPair, ConsensusClient consensusClient) { this.hashAlgorithm = hashAlgorithm; this.nodeKeyPair = nodeKeyPair; this.consensusClient = consensusClient; diff --git a/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java b/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java index 9fb5674d..56f0b12a 100644 --- a/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java +++ b/source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java @@ -4,7 +4,7 @@ import com.jd.blockchain.consensus.*; import com.jd.blockchain.consensus.client.ClientFactory; import com.jd.blockchain.consensus.client.ClientSettings; import com.jd.blockchain.consensus.client.ConsensusClient; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.ledger.CryptoSetting; import com.jd.blockchain.ledger.data.TransactionService; @@ -88,7 +88,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C * * @return 区块链服务工厂实例; */ - public static PeerBlockchainServiceFactory connect(CryptoKeyPair gatewayKey, NetworkAddress peerAddr, List peerProviders) { + public static PeerBlockchainServiceFactory connect(AsymmetricKeypair gatewayKey, NetworkAddress peerAddr, List peerProviders) { if (peerProviders == null || peerProviders.isEmpty()) { throw new AuthenticationException("No peer Provider was set!"); @@ -245,7 +245,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C * @param cryptoSetting * @return */ - private static TransactionService enableGatewayAutoSigning(CryptoKeyPair nodeKeyPair, CryptoSetting cryptoSetting, + private static TransactionService enableGatewayAutoSigning(AsymmetricKeypair nodeKeyPair, CryptoSetting cryptoSetting, ConsensusClient consensusClient) { NodeSigningAppender signingAppender = new NodeSigningAppender(cryptoSetting.getHashAlgorithm(), nodeKeyPair, consensusClient); @@ -265,7 +265,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C } } - private static ClientIdentificationsProvider authIdProvider(CryptoKeyPair gatewayKey, List peerProviders) { + private static ClientIdentificationsProvider authIdProvider(AsymmetricKeypair gatewayKey, List peerProviders) { ClientIdentificationsProvider authIdProvider = new ClientIdentificationsProvider(); for (String peerProvider : peerProviders) { ConsensusProvider provider = ConsensusProviders.getProvider(peerProvider); diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java index fa00eaee..a4479baf 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java @@ -1,6 +1,6 @@ package com.jd.blockchain.sdk.samples; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -88,7 +88,7 @@ public class SDKDemo_Contract { String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -107,9 +107,9 @@ public class SDKDemo_Contract { * * @return */ - private static CryptoKeyPair getSponsorKey() { + private static AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } /** diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java index 89e2b495..f823e5ce 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java @@ -1,6 +1,6 @@ package com.jd.blockchain.sdk.samples; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -61,7 +61,7 @@ public class SDKDemo_DataAccount { PreparedTransaction prepTx = txTemp.prepare(); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -73,9 +73,9 @@ public class SDKDemo_DataAccount { return null; } - private static CryptoKeyPair getSponsorKey() { + private static AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } } diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java index bae85e97..1a98ff59 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java @@ -1,6 +1,6 @@ package com.jd.blockchain.sdk.samples; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -67,7 +67,7 @@ public class SDKDemo_InsertData { String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -79,9 +79,9 @@ public class SDKDemo_InsertData { return null; } - private static CryptoKeyPair getSponsorKey() { + private static AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } /** diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java index a03685b3..62ef554c 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java @@ -1,7 +1,7 @@ package com.jd.blockchain.sdk.samples; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.ledger.*; import com.jd.blockchain.sdk.BlockchainService; @@ -37,7 +37,7 @@ public class SDKDemo_RegisterAccount { TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); //existed signer - CryptoKeyPair keyPair = new BlockchainKeyPair(SDKDemo_Params.pubKey1, SDKDemo_Params.privkey1); + AsymmetricKeypair keyPair = new BlockchainKeyPair(SDKDemo_Params.pubKey1, SDKDemo_Params.privkey1); BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate(); diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java index ab62fb31..e1374bca 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java @@ -9,7 +9,7 @@ package com.jd.blockchain.sdk.samples; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java index e0f16518..c382da6a 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java @@ -9,7 +9,7 @@ package com.jd.blockchain.sdk.samples; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -58,7 +58,7 @@ public class SDKDemo_RegisterUser { TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); //existed signer - CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey); + AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); diff --git a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java index ed177e32..f7832e6e 100644 --- a/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java +++ b/source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java @@ -1,6 +1,6 @@ package com.jd.blockchain.sdk.samples; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.SignatureFunction; @@ -64,7 +64,7 @@ public class SDKDemo_User { //BlockchainKeyPair user = generator.generate(CryptoKeyType.PUBLIC); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); BlockchainKeyPair user = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); txTemp.users().register(user.getIdentity()); @@ -75,7 +75,7 @@ public class SDKDemo_User { PreparedTransaction prepTx = txTemp.prepare(); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -87,9 +87,9 @@ public class SDKDemo_User { return null; } - private static CryptoKeyPair getSponsorKey() { + private static AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } } diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java index 4e7d3ffc..a0e4187d 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -99,7 +99,7 @@ public class SDK_GateWay_BatchInsertData_Test_ { PreparedTransaction prepTx = txTemp.prepare(); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -123,9 +123,9 @@ public class SDK_GateWay_BatchInsertData_Test_ { } - private CryptoKeyPair getSponsorKey() { + private AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } private TransactionResponse initResponse() { diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java index 29eda300..dab14571 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -81,7 +81,7 @@ public class SDK_GateWay_DataAccount_Test_ { // CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); //existed signer - CryptoKeyPair keyPair = new BlockchainKeyPair(SDK_GateWay_KeyPair_Para.pubKey1, SDK_GateWay_KeyPair_Para.privkey1); + AsymmetricKeypair keyPair = new BlockchainKeyPair(SDK_GateWay_KeyPair_Para.pubKey1, SDK_GateWay_KeyPair_Para.privkey1); BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate(); @@ -118,8 +118,8 @@ public class SDK_GateWay_DataAccount_Test_ { return CryptoServiceProviders.getSignatureFunction("ED25519"); } - private CryptoKeyPair getSponsorKey() { - return getSignatureFunction().generateKeyPair(); + private AsymmetricKeypair getSponsorKey() { + return getSignatureFunction().generateKeypair(); } private TransactionResponse initResponse() { diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java index 271b18e7..10881601 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -92,7 +92,7 @@ public class SDK_GateWay_InsertData_Test_ { PreparedTransaction prepTx = txTemp.prepare(); // 使用私钥进行签名; - CryptoKeyPair keyPair = getSponsorKey(); + AsymmetricKeypair keyPair = getSponsorKey(); prepTx.sign(keyPair); // 提交交易; @@ -117,9 +117,9 @@ public class SDK_GateWay_InsertData_Test_ { } - private CryptoKeyPair getSponsorKey() { + private AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } private TransactionResponse initResponse() { diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java index 77d63d3d..ce052815 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -186,7 +186,7 @@ public class SDK_GateWay_Query_Test_ { private BlockchainKeyPair getSponsorKey() { SignatureFunction signatureFunction = getSignatureFunction(); - CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); + AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); BlockchainKeyPair blockchainKeyPair = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); return blockchainKeyPair; diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java index f2bcf4ef..aa98e0df 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.junit.Test; import com.jd.blockchain.binaryproto.DataContractRegistry; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashFunction; @@ -103,7 +103,7 @@ public class SDK_GateWay_User_Test_ { TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); //existed signer - CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey); + AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); @@ -137,9 +137,9 @@ public class SDK_GateWay_User_Test_ { // return new HashDigest(hashBytes); // } - private CryptoKeyPair getSponsorKey() { + private AsymmetricKeypair getSponsorKey() { SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); - return signatureFunction.generateKeyPair(); + return signatureFunction.generateKeypair(); } private TransactionResponse initResponse() { diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java index c2eb308c..ef543c42 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.Map; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.ledger.core.impl.LedgerManager; import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory; import com.jd.blockchain.tools.initializer.LedgerBindingConfig; @@ -37,7 +37,7 @@ public class IntegratedContext { private int id; - private CryptoKeyPair partiKeyPair; + private AsymmetricKeypair partiKeyPair; // private NetworkAddress consensusAddress; private ConsensusSettings consensusSettings; @@ -64,11 +64,11 @@ public class IntegratedContext { return storageDB; } - public CryptoKeyPair getPartiKeyPair() { + public AsymmetricKeypair getPartiKeyPair() { return partiKeyPair; } - public void setPartiKeyPair(CryptoKeyPair partiKeyPair) { + public void setPartiKeyPair(AsymmetricKeypair partiKeyPair) { this.partiKeyPair = partiKeyPair; } diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java index e0041cc3..45d44fe1 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java @@ -14,7 +14,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -169,7 +169,7 @@ public class IntegrationTest { HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); - CryptoKeyPair adminKey = context.getNode(0).getPartiKeyPair(); + AsymmetricKeypair adminKey = context.getNode(0).getPartiKeyPair(); BlockchainKeyPair newUserAcount = testSDK_RegisterUser(adminKey, ledgerHashs[0], bcsrv, context); @@ -184,7 +184,7 @@ public class IntegrationTest { } - private void testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + private void testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, String dataAccountAddress, IntegratedContext context) { // 在本地定义注册账号的 TX; @@ -223,7 +223,7 @@ public class IntegrationTest { } } - private static BlockchainKeyPair testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, + private static BlockchainKeyPair testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context) { // 注册用户,并验证最终写入; BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); @@ -253,7 +253,7 @@ public class IntegrationTest { return user; } - private BlockchainKeyPair testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, + private BlockchainKeyPair testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context) { // 注册数据账户,并验证最终写入; BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); @@ -286,7 +286,7 @@ public class IntegrationTest { return dataAccount; } - private void testSDK_Query(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + private void testSDK_Query(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context, BlockchainKeyPair newUserAcount, BlockchainKeyPair newDataAcount) { Bytes userAddress = newUserAcount.getAddress(); @@ -501,7 +501,7 @@ public class IntegrationTest { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -509,7 +509,7 @@ public class IntegrationTest { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -517,7 +517,7 @@ public class IntegrationTest { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -525,7 +525,7 @@ public class IntegrationTest { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); @@ -547,7 +547,7 @@ public class IntegrationTest { } } - private LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, + private LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context) { // valid the basic data in contract; prepareContractData(adminKey, ledgerHash, blockchainService, context); @@ -585,7 +585,7 @@ public class IntegrationTest { return block; } - private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, + private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, BlockchainService blockchainService, IntegratedContext context) { LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); @@ -616,7 +616,7 @@ public class IntegrationTest { // 验证合约中的赋值,外部可以获得; DataAccountSet dataAccountSet = ledgerOfNode0.getDataAccountSet(backgroundLedgerBlock); - CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); + AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); PubKey pubKey = key.getPubKey(); Bytes dataAddress = AddressEncoding.generateAddress(pubKey); @@ -629,7 +629,7 @@ public class IntegrationTest { // assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); } - private void prepareContractData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + private void prepareContractData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context) { // 定义交易; diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java index 4f3c988d..05d5bcfb 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java @@ -14,7 +14,7 @@ import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -162,7 +162,7 @@ public class ConsensusTest { } private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, - CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { + AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length]; for (int i = 0; i < ptxs.length; i++) { // 定义交易; @@ -252,7 +252,7 @@ public class ConsensusTest { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -260,7 +260,7 @@ public class ConsensusTest { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -268,7 +268,7 @@ public class ConsensusTest { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -276,7 +276,7 @@ public class ConsensusTest { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java index aa8eb7e2..b82756a2 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java @@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.SignatureDigest; @@ -160,7 +160,7 @@ public class GlobalPerformanceTest { } private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, - CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { + AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length]; for (int i = 0; i < ptxs.length; i++) { // 定义交易; @@ -250,7 +250,7 @@ public class GlobalPerformanceTest { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -258,7 +258,7 @@ public class GlobalPerformanceTest { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -266,7 +266,7 @@ public class GlobalPerformanceTest { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -274,7 +274,7 @@ public class GlobalPerformanceTest { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java index 2daf30b1..2a79f663 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java @@ -12,7 +12,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -168,9 +168,9 @@ public class LedgerInitializeTest { private LedgerInitProcess initProcess; - private CryptoKeyPair partiKey; + private AsymmetricKeypair partiKey; - public CryptoKeyPair getPartiKey() { + public AsymmetricKeypair getPartiKey() { return partiKey; } @@ -198,7 +198,7 @@ public class LedgerInitializeTest { ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, Prompter prompter) { - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override @@ -219,7 +219,7 @@ public class LedgerInitializeTest { cryptoSetting.setAutoVerifyHash(autoVerifyHash); cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java index 89dadcd9..7071a2dc 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java @@ -17,7 +17,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -178,7 +178,7 @@ public class LedgerPerformanceTest { * @param batchCount * @param silent */ - private static void testUserRegistering(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, + private static void testUserRegistering(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [注册用户] ================="); @@ -219,7 +219,7 @@ public class LedgerPerformanceTest { * @param batchCount * @param silent */ - private static void testKVWrite(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, + private static void testKVWrite(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [写入数据] ================="); @@ -273,7 +273,7 @@ public class LedgerPerformanceTest { * @param batchCount * @param silent */ - private static void testContract(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, + private static void testContract(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [执行合约] ================="); @@ -356,7 +356,7 @@ public class LedgerPerformanceTest { } public static List prepareUserRegisterRequests(HashDigest ledgerHash, int count, - CryptoKeyPair adminKey) { + AsymmetricKeypair adminKey) { long startTs = System.currentTimeMillis(); List txList = new ArrayList<>(); for (int i = 0; i < count; i++) { @@ -376,7 +376,7 @@ public class LedgerPerformanceTest { } public static List prepareDataAccountRegisterRequests(HashDigest ledgerHash, - BlockchainIdentity[] dataAccounts, CryptoKeyPair adminKey, boolean statistic) { + BlockchainIdentity[] dataAccounts, AsymmetricKeypair adminKey, boolean statistic) { int count = dataAccounts.length; long startTs = System.currentTimeMillis(); List txList = new ArrayList<>(); @@ -400,7 +400,7 @@ public class LedgerPerformanceTest { } public static List prepareDataWriteRequests(HashDigest ledgerHash, - BlockchainIdentity[] dataAccounts, int count, CryptoKeyPair adminKey, boolean statistic) { + BlockchainIdentity[] dataAccounts, int count, AsymmetricKeypair adminKey, boolean statistic) { long startTs = System.currentTimeMillis(); List txList = new ArrayList<>(); for (int i = 0; i < count; i++) { @@ -428,7 +428,7 @@ public class LedgerPerformanceTest { return ConsensusProviders.getProvider(provider); } public static List prepareContractRequests(HashDigest ledgerHash, - CryptoKeyPair adminKey, int count, boolean statistic, TransactionBatchProcessor txProc) { + AsymmetricKeypair adminKey, int count, boolean statistic, TransactionBatchProcessor txProc) { // deploy contract byte[] chainCode; diff --git a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java index 365164e0..96064d80 100644 --- a/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java +++ b/source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java @@ -11,7 +11,7 @@ import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -81,9 +81,9 @@ public class Utils { private LedgerInitProcess initProcess; - private CryptoKeyPair partiKey; + private AsymmetricKeypair partiKey; - public CryptoKeyPair getPartiKey() { + public AsymmetricKeypair getPartiKey() { return partiKey; } @@ -109,7 +109,7 @@ public class Utils { ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, Prompter prompter) { - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override @@ -145,7 +145,7 @@ public class Utils { ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, Prompter prompter, CryptoSetting cryptoSetting) { - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java index 5e7133df..74131190 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java @@ -10,7 +10,7 @@ package test.com.jd.blockchain.intgr; import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.ledger.*; import com.jd.blockchain.ledger.core.LedgerManage; @@ -73,7 +73,7 @@ public class IntegrationBase { public static final AtomicLong validLong = new AtomicLong(); - public static KeyPairResponse testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { + public static KeyPairResponse testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { // 注册用户,并验证最终写入; BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); @@ -98,7 +98,7 @@ public class IntegrationBase { return keyPairResponse; } - public static KeyPairResponse testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { + public static KeyPairResponse testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { // 注册数据账户,并验证最终写入; BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); @@ -123,7 +123,7 @@ public class IntegrationBase { return keyPairResponse; } - public static KvResponse testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + public static KvResponse testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, Bytes dataAccount) { // 在本地定义注册账号的 TX; @@ -440,7 +440,7 @@ public class IntegrationBase { HashDigest txContentHash; String pubKeyVal = "jd.com"+System.currentTimeMillis(); private String eventName = "issue-asset"; - public LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, + public LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService,LedgerRepository ledgerRepository) { System.out.println("adminKey="+ AddressEncoding.generateAddress(adminKey.getPubKey())); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); @@ -475,7 +475,7 @@ public class IntegrationBase { return block; } - private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, + private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, BlockchainService blockchainService,LedgerRepository ledgerRepository) { LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java index 32d57373..da0e82b8 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java @@ -3,7 +3,7 @@ package test.com.jd.blockchain.intgr; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; @@ -197,7 +197,7 @@ public class IntegrationBaseTest { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -205,7 +205,7 @@ public class IntegrationBaseTest { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -213,7 +213,7 @@ public class IntegrationBaseTest { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -221,7 +221,7 @@ public class IntegrationBaseTest { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java index cf89e96c..c4e4c4c4 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java @@ -18,7 +18,7 @@ import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; @@ -150,7 +150,7 @@ public class IntegrationTest2 { HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); - CryptoKeyPair adminKey = context.getNode(0).getPartiKeyPair(); + AsymmetricKeypair adminKey = context.getNode(0).getPartiKeyPair(); testSDK_Contract(adminKey, ledgerHashs[0], bcsrv, context); @@ -239,7 +239,7 @@ public class IntegrationTest2 { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -247,7 +247,7 @@ public class IntegrationTest2 { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -255,7 +255,7 @@ public class IntegrationTest2 { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -263,7 +263,7 @@ public class IntegrationTest2 { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); @@ -285,7 +285,7 @@ public class IntegrationTest2 { } } - private void testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, + private void testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, IntegratedContext context) { BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); @@ -307,7 +307,7 @@ public class IntegrationTest2 { testContractExe(adminKey, ledgerHash, userKey, blockchainService, context); } - private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, + private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, BlockchainService blockchainService, IntegratedContext context) { LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight()-1); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java index fbe8d383..effd220c 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java @@ -1,6 +1,6 @@ package test.com.jd.blockchain.intgr; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -101,7 +101,7 @@ public class IntegrationTest4Bftsmart { PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); - CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); + AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); BlockchainService blockchainService = gwsrvFact.getBlockchainService(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java index 7a7dd71c..64cbe4c8 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java @@ -1,6 +1,6 @@ package test.com.jd.blockchain.intgr; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -111,7 +111,7 @@ public class IntegrationTest4MQ { PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); - CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); + AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); BlockchainService blockchainService = gwsrvFact.getBlockchainService(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java index 3ee17bfa..8b1aab73 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java @@ -15,7 +15,7 @@ import org.junit.Test; import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.crypto.AddressEncoding; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -145,7 +145,7 @@ public class IntegrationTestAll4Redis { PubKey pubKey2 = KeyGenCommand.decodePubKey(PUB_KEYS[2]); PubKey pubKey3 = KeyGenCommand.decodePubKey(PUB_KEYS[3]); - CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); + AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); testWriteBatchTransactions(gateway0, adminKey, ledgers[0]); @@ -202,7 +202,7 @@ public class IntegrationTestAll4Redis { } // 测试一个区块包含多个交易的写入情况,并验证写入结果; - private void testWriteBatchTransactions(GatewayTestRunner gateway, CryptoKeyPair adminKey, + private void testWriteBatchTransactions(GatewayTestRunner gateway, AsymmetricKeypair adminKey, LedgerRepository ledgerRepository) { // 连接网关; GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); @@ -257,7 +257,7 @@ public class IntegrationTestAll4Redis { return; } - private void testSDK(GatewayTestRunner gateway, CryptoKeyPair adminKey, LedgerRepository ledgerRepository) { + private void testSDK(GatewayTestRunner gateway, AsymmetricKeypair adminKey, LedgerRepository ledgerRepository) { // 连接网关; GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); BlockchainService bcsrv = gwsrvFact.getBlockchainService(); @@ -271,7 +271,7 @@ public class IntegrationTestAll4Redis { } - private void testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + private void testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, Bytes dataAccountAddress, LedgerRepository ledgerRepository) { // 在本地定义注册账号的 TX; @@ -315,7 +315,7 @@ public class IntegrationTestAll4Redis { } } - private BlockchainKeyPair testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, + private BlockchainKeyPair testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, LedgerRepository ledgerRepository) { // 注册数据账户,并验证最终写入; BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); @@ -350,7 +350,7 @@ public class IntegrationTestAll4Redis { return dataAccount; } - private BlockchainKeyPair testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, + private BlockchainKeyPair testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, LedgerRepository ledgerRepository) { // 注册用户,并验证最终写入; BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); @@ -390,7 +390,7 @@ public class IntegrationTestAll4Redis { } } - private LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, + private LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, LedgerRepository ledgerRepository) { System.out.println("adminKey=" + AddressEncoding.generateAddress(adminKey.getPubKey())); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); @@ -442,7 +442,7 @@ public class IntegrationTestAll4Redis { return block; } - private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, + private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, BlockchainService blockchainService, LedgerRepository ledgerRepository) { LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); @@ -474,7 +474,7 @@ public class IntegrationTestAll4Redis { // 验证合约中的赋值,外部可以获得; DataAccountSet dataAccountSet = ledgerRepository.getDataAccountSet(backgroundLedgerBlock); - CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); + AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); PubKey pubKey = key.getPubKey(); Bytes dataAddress = AddressEncoding.generateAddress(pubKey); assertEquals(dataAddress, dataAccountSet.getDataAccount(dataAddress).getAddress()); @@ -489,7 +489,7 @@ public class IntegrationTestAll4Redis { // assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); } - private void prepareContractData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, + private void prepareContractData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, LedgerRepository ledgerRepository) { // 定义交易; diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java index 16a5ac57..f4d8a9b1 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java @@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSON; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -126,7 +126,7 @@ public class IntegrationTestDataAccount { PrivKey privkey0 = KeyGenCommand.decodePrivKeyWithRawPassword(LedgerInitializeWeb4SingleStepsTest.PRIV_KEYS[0], LedgerInitializeWeb4SingleStepsTest.PASSWORD); PubKey pubKey0 = KeyGenCommand.decodePubKey(LedgerInitializeWeb4SingleStepsTest.PUB_KEYS[0]); - CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); + AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); // regist data account Bytes dataAddr = registDataAccount(gateway0, adminKey, context); @@ -138,7 +138,7 @@ public class IntegrationTestDataAccount { testConsistencyAmongNodes(context); } - private Bytes registDataAccount(GatewayTestRunner gateway, CryptoKeyPair adminKey, IntegratedContext context) { + private Bytes registDataAccount(GatewayTestRunner gateway, AsymmetricKeypair adminKey, IntegratedContext context) { // 连接网关; GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); BlockchainService blockchainService = gwsrvFact.getBlockchainService(); @@ -173,7 +173,7 @@ public class IntegrationTestDataAccount { } // 通过调用SDK->GATEWAY,测试一个区块包含多个交易时的写入情况,并验证写入结果; - private void testAddKvOpToDataAccount(GatewayTestRunner gateway, CryptoKeyPair adminKey, IntegratedContext context, + private void testAddKvOpToDataAccount(GatewayTestRunner gateway, AsymmetricKeypair adminKey, IntegratedContext context, Bytes dataAddr) { GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); @@ -335,7 +335,7 @@ public class IntegrationTestDataAccount { node0.setConsensusSettings(csProps); node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setStorageDB(nodeCtx0.getStorageDB()); - node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); + node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); node0.setBindingConfig(bindingConfig0); context.addNode(node0); @@ -343,7 +343,7 @@ public class IntegrationTestDataAccount { node1.setConsensusSettings(csProps); node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setStorageDB(nodeCtx1.getStorageDB()); - node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); + node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); node1.setBindingConfig(bindingConfig1); context.addNode(node1); @@ -351,7 +351,7 @@ public class IntegrationTestDataAccount { node2.setConsensusSettings(csProps); node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setStorageDB(nodeCtx2.getStorageDB()); - node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); + node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); node2.setBindingConfig(bindingConfig2); context.addNode(node2); @@ -359,7 +359,7 @@ public class IntegrationTestDataAccount { node3.setConsensusSettings(csProps); node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setStorageDB(nodeCtx3.getStorageDB()); - node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); + node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); node3.setBindingConfig(bindingConfig3); context.addNode(node3); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java index 4b973707..7c659012 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java @@ -8,7 +8,7 @@ */ package test.com.jd.blockchain.intgr.batch.bftsmart; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -181,7 +181,7 @@ public class BftsmartLedgerInit { PubKey pubKey0 = KeyGenCommand.decodePubKey(BftsmartConfig.PUB_KEY[0]); - CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); + AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); BlockchainService blockchainService = gwsrvFact.getBlockchainService(); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java index c550dc69..05424499 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java @@ -13,7 +13,7 @@ import static com.jd.blockchain.tools.keygen.KeyGenCommand.encodePubKey; import org.junit.Test; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.utils.codec.Base58Utils; @@ -38,7 +38,7 @@ public class BftsmartTestBase { public void newUsers() { SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); for (int i = 0; i < userSize; i++) { - CryptoKeyPair kp = signFunc.generateKeyPair(); + AsymmetricKeypair kp = signFunc.generateKeypair(); String base58PubKey = encodePubKey(kp.getPubKey()); diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java index a3d59fb0..f0ab90ae 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java @@ -19,7 +19,7 @@ import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.crypto.AddressEncoding; import com.jd.blockchain.crypto.CryptoAlgorithm; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; @@ -211,9 +211,9 @@ public class LedgerInitializeTest { private LedgerInitProcess initProcess; - private CryptoKeyPair partiKey; + private AsymmetricKeypair partiKey; - public CryptoKeyPair getPartiKey() { + public AsymmetricKeypair getPartiKey() { return partiKey; } @@ -237,7 +237,7 @@ public class LedgerInitializeTest { ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, Prompter prompter) { - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override @@ -258,7 +258,7 @@ public class LedgerInitializeTest { cryptoSetting.setAutoVerifyHash(autoVerifyHash); cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); - partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); + partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); ThreadInvoker invoker = new ThreadInvoker() { @Override diff --git a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java index 88ed3a41..b11d76c3 100644 --- a/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java +++ b/source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java @@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource; import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.ledger.BlockchainKeyGenerator; @@ -63,7 +63,7 @@ public class LedgerBlockGeneratingTest { test(ledgerHash, node.getPartiKey(), ledgerManager, opHandler, 1000, 5); } - private static void test(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, + private static void test(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount) { LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); long height = ledger.getLatestBlockHeight(); @@ -106,7 +106,7 @@ public class LedgerBlockGeneratingTest { } private static List prepareUserRegisterRequests(HashDigest ledgerHash, int count, - CryptoKeyPair adminKey) { + AsymmetricKeypair adminKey) { List txList = new ArrayList<>(); for (int i = 0; i < count; i++) { TxBuilder txbuilder = new TxBuilder(ledgerHash); diff --git a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java index 68cfd80a..3adcf445 100644 --- a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java +++ b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java @@ -21,7 +21,7 @@ import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.capability.settings.CapabilitySettings; import com.jd.blockchain.consensus.mq.factory.MsgQueueFactory; import com.jd.blockchain.consensus.mq.producer.MsgQueueProducer; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.ledger.BlockchainIdentity; import com.jd.blockchain.ledger.BlockchainKeyGenerator; @@ -317,7 +317,7 @@ public class RemoteTransactionService { return txSerializeBytes; } - private TransactionRequest userRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) { + private TransactionRequest userRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) { TxBuilder txbuilder = new TxBuilder(ledgerHash); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); txbuilder.users().register(userKey.getIdentity()); @@ -326,7 +326,7 @@ public class RemoteTransactionService { return reqBuilder.buildRequest(); } - private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey, boolean isSave) { + private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey, boolean isSave) { TxBuilder txbuilder = new TxBuilder(ledgerHash); BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainIdentity identity = dataAccountKey.getIdentity(); @@ -339,7 +339,7 @@ public class RemoteTransactionService { return reqBuilder.buildRequest(); } - private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) { + private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) { TxBuilder txbuilder = new TxBuilder(ledgerHash); BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainIdentity identity = dataAccountKey.getIdentity(); @@ -350,7 +350,7 @@ public class RemoteTransactionService { return reqBuilder.buildRequest(); } - private TransactionRequest kvStorageRequest(Bytes address, HashDigest ledgerHash, CryptoKeyPair adminKey) { + private TransactionRequest kvStorageRequest(Bytes address, HashDigest ledgerHash, AsymmetricKeypair adminKey) { TxBuilder txbuilder = new TxBuilder(ledgerHash); long currValue = keyPrefix.getAndIncrement(); txbuilder.dataAccount(address).set("key-" + currValue + "-" + System.currentTimeMillis(), diff --git a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java index 5ab9e6bb..4723d615 100644 --- a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java +++ b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java @@ -13,7 +13,7 @@ import com.jd.blockchain.capability.settings.CapabilitySettings; import com.jd.blockchain.consensus.action.ActionResponse; import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings; import com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -118,7 +118,7 @@ public class SettingsInit { // 处理用户 PrivKey privKey = KeyGenCommand.decodePrivKeyWithRawPassword(settings.getPrivKey(), settings.getPwd()); PubKey pubKey = KeyGenCommand.decodePubKey(settings.getPubKey()); - CapabilitySettings.adminKey = new CryptoKeyPair(pubKey, privKey); + CapabilitySettings.adminKey = new AsymmetricKeypair(pubKey, privKey); } private static class Settings { diff --git a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java index ee4bd914..081fe6dd 100644 --- a/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java +++ b/source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java @@ -8,7 +8,7 @@ */ package com.jd.blockchain.capability.settings; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.HashDigest; /** @@ -41,7 +41,7 @@ public class CapabilitySettings { public static HashDigest ledgerHash; - public static CryptoKeyPair adminKey; + public static AsymmetricKeypair adminKey; public static final String settingsConf = "settings.conf"; } \ No newline at end of file diff --git a/source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java b/source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java index bf071822..e9b37976 100644 --- a/source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java +++ b/source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java @@ -8,7 +8,7 @@ import java.util.List; import javax.crypto.SecretKey; -import com.jd.blockchain.crypto.CryptoKeyPair; +import com.jd.blockchain.crypto.AsymmetricKeypair; import com.jd.blockchain.crypto.CryptoServiceProviders; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PubKey; @@ -104,7 +104,7 @@ public class KeyGenCommand { * @param outputDir */ private static void generateKeyPair(String name, String outputDir, String localConfPath) { - CryptoKeyPair kp = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); + AsymmetricKeypair kp = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); String base58PubKey = encodePubKey(kp.getPubKey());