Browse Source

Rename some of the types in crypto framework for more accurate expression.

tags/1.0.0
huanghaiquan 6 years ago
parent
commit
047eecf054
74 changed files with 283 additions and 277 deletions
  1. +2
    -2
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java
  2. +2
    -2
      source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java
  3. +2
    -2
      source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java
  4. +1
    -1
      source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java
  5. +2
    -2
      source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java
  6. +3
    -3
      source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java
  7. +2
    -2
      source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java
  8. +11
    -11
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java
  9. +1
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java
  10. +8
    -2
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypair.java
  11. +10
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java
  12. +0
    -10
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java
  13. +0
    -9
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java
  14. +1
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java
  15. +1
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java
  16. +1
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java
  17. +9
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java
  18. +3
    -3
      source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java
  19. +1
    -1
      source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java
  20. +14
    -14
      source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java
  21. +3
    -3
      source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java
  22. +2
    -2
      source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java
  23. +4
    -4
      source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java
  24. +4
    -4
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java
  25. +5
    -5
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java
  26. +3
    -3
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java
  27. +2
    -2
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java
  28. +2
    -2
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java
  29. +2
    -2
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java
  30. +3
    -3
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java
  31. +2
    -2
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java
  32. +4
    -4
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java
  33. +1
    -1
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java
  34. +1
    -1
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java
  35. +2
    -2
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java
  36. +2
    -2
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java
  37. +5
    -5
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java
  38. +2
    -2
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java
  39. +3
    -3
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java
  40. +4
    -4
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java
  41. +4
    -4
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java
  42. +4
    -4
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java
  43. +4
    -4
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java
  44. +2
    -2
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java
  45. +1
    -1
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java
  46. +2
    -2
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java
  47. +5
    -5
      source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java
  48. +4
    -4
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java
  49. +4
    -4
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java
  50. +4
    -4
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java
  51. +2
    -2
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java
  52. +4
    -4
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java
  53. +4
    -4
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java
  54. +14
    -14
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java
  55. +6
    -6
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java
  56. +6
    -6
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java
  57. +5
    -5
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java
  58. +8
    -8
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java
  59. +5
    -5
      source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java
  60. +6
    -6
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java
  61. +5
    -5
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java
  62. +8
    -8
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java
  63. +2
    -2
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java
  64. +2
    -2
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java
  65. +11
    -11
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java
  66. +8
    -8
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java
  67. +2
    -2
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java
  68. +2
    -2
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java
  69. +5
    -5
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java
  70. +3
    -3
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java
  71. +5
    -5
      source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java
  72. +2
    -2
      source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java
  73. +2
    -2
      source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java
  74. +2
    -2
      source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java

+ 2
- 2
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClientFactory.java View File

@@ -10,7 +10,7 @@ import com.jd.blockchain.consensus.bftsmart.BftsmartClientIncomingSettings;
import com.jd.blockchain.consensus.client.ClientFactory; import com.jd.blockchain.consensus.client.ClientFactory;
import com.jd.blockchain.consensus.client.ClientSettings; import com.jd.blockchain.consensus.client.ClientSettings;
import com.jd.blockchain.consensus.client.ConsensusClient; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -32,7 +32,7 @@ public class BftsmartConsensusClientFactory implements ClientFactory {




@Override @Override
public BftsmartClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) {
public BftsmartClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) {


PubKey pubKey = clientKeyPair.getPubKey(); PubKey pubKey = clientKeyPair.getPubKey();
PrivKey privKey = clientKeyPair.getPrivKey(); PrivKey privKey = clientKeyPair.getPrivKey();


+ 2
- 2
source/consensus/consensus-framework/src/main/java/com/jd/blockchain/consensus/client/ClientFactory.java View File

@@ -3,7 +3,7 @@ package com.jd.blockchain.consensus.client;
import com.jd.blockchain.consensus.ClientIdentification; import com.jd.blockchain.consensus.ClientIdentification;
import com.jd.blockchain.consensus.ClientIncomingSettings; import com.jd.blockchain.consensus.ClientIncomingSettings;
import com.jd.blockchain.consensus.ConsensusManageService; import com.jd.blockchain.consensus.ConsensusManageService;
import com.jd.blockchain.crypto.CryptoKeyPair;
import com.jd.blockchain.crypto.AsymmetricKeypair;


public interface ClientFactory { public interface ClientFactory {


@@ -13,7 +13,7 @@ public interface ClientFactory {
* @param clientKeyPair * @param clientKeyPair
* @return * @return
*/ */
ClientIdentification buildAuthId(CryptoKeyPair clientKeyPair);
ClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair);


/** /**
* 根据接入配置信息创建客户端的本地连接配置; * 根据接入配置信息创建客户端的本地连接配置;


+ 2
- 2
source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/client/MsgQueueClientFactory.java View File

@@ -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.MsgQueueClientIncomingSettings;
import com.jd.blockchain.consensus.mq.settings.MsgQueueClientSettings; import com.jd.blockchain.consensus.mq.settings.MsgQueueClientSettings;
import com.jd.blockchain.consensus.mq.settings.MsgQueueConsensusSettings; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -32,7 +32,7 @@ import com.jd.blockchain.crypto.SignatureFunction;
public class MsgQueueClientFactory implements ClientFactory { public class MsgQueueClientFactory implements ClientFactory {


@Override @Override
public MsgQueueClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) {
public MsgQueueClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) {
PubKey pubKey = clientKeyPair.getPubKey(); PubKey pubKey = clientKeyPair.getPubKey();
byte[] address = pubKey.toBytes(); // 使用公钥地址作为认证信息 byte[] address = pubKey.toBytes(); // 使用公钥地址作为认证信息




+ 1
- 1
source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/AESEncryptionFunction.java View File

@@ -221,7 +221,7 @@ public class AESEncryptionFunction implements SymmetricEncryptionFunction {
} }


@Override @Override
public CryptoKey generateSymmetricKey() {
public SymmetricKey generateSymmetricKey() {
// 根据对应的标识和原始密钥生成相应的密钥数据 // 根据对应的标识和原始密钥生成相应的密钥数据
return new SymmetricKey(AES, AESUtils.generateKey128_Bytes()); return new SymmetricKey(AES, AESUtils.generateKey128_Bytes());
} }


+ 2
- 2
source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunction.java View File

@@ -1,7 +1,7 @@
package com.jd.blockchain.crypto.service.classic; package com.jd.blockchain.crypto.service.classic;


import com.jd.blockchain.crypto.CryptoAlgorithm; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -63,7 +63,7 @@ public class ECDSASignatureFunction implements SignatureFunction {
} }


@Override @Override
public CryptoKeyPair generateKeyPair() {
public AsymmetricKeypair generateKeypair() {
return null; return null;
} }
} }

+ 3
- 3
source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunction.java View File

@@ -7,7 +7,7 @@ import static com.jd.blockchain.crypto.CryptoKeyType.PUBLIC;


import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoAlgorithm;
import com.jd.blockchain.crypto.CryptoException; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -154,7 +154,7 @@ public class ED25519SignatureFunction implements SignatureFunction {
} }


@Override @Override
public CryptoKeyPair generateKeyPair() {
public AsymmetricKeypair generateKeypair() {
// 调用ED25519算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 // 调用ED25519算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对
AsymmetricCipherKeyPair keyPair = ED25519Utils.generateKeyPair(); AsymmetricCipherKeyPair keyPair = ED25519Utils.generateKeyPair();
Ed25519PrivateKeyParameters privKeyParams = (Ed25519PrivateKeyParameters) keyPair.getPrivate(); Ed25519PrivateKeyParameters privKeyParams = (Ed25519PrivateKeyParameters) keyPair.getPrivate();
@@ -167,7 +167,7 @@ public class ED25519SignatureFunction implements SignatureFunction {
// EdDSAPrivateKey privKey = (EdDSAPrivateKey) keyPair.getPrivate(); // EdDSAPrivateKey privKey = (EdDSAPrivateKey) keyPair.getPrivate();
// EdDSAPublicKey pubKey = (EdDSAPublicKey) keyPair.getPublic(); // EdDSAPublicKey pubKey = (EdDSAPublicKey) keyPair.getPublic();
// return new CryptoKeyPair(new PubKey(ED25519, pubKey.getAbyte()), new PrivKey(ED25519, privKey.getSeed())); // 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));


} }
} }

+ 2
- 2
source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/service/classic/RSACryptoFunction.java View File

@@ -4,7 +4,7 @@ import com.jd.blockchain.crypto.AsymmetricCiphertext;
import com.jd.blockchain.crypto.AsymmetricEncryptionFunction; import com.jd.blockchain.crypto.AsymmetricEncryptionFunction;
import com.jd.blockchain.crypto.Ciphertext; import com.jd.blockchain.crypto.Ciphertext;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -88,7 +88,7 @@ public class RSACryptoFunction implements AsymmetricEncryptionFunction, Signatur
} }


@Override @Override
public CryptoKeyPair generateKeyPair() {
public AsymmetricKeypair generateKeypair() {
return null; return null;
} }
} }

+ 11
- 11
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java View File

@@ -17,7 +17,7 @@ import org.junit.Test;


import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoAlgorithm;
import com.jd.blockchain.crypto.CryptoException; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -64,7 +64,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -97,7 +97,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -122,7 +122,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
SignatureDigest signatureDigest = signatureFunction.sign(privKey,data); SignatureDigest signatureDigest = signatureFunction.sign(privKey,data);
@@ -150,7 +150,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -168,7 +168,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
byte[] privKeyBytes = privKey.toBytes(); byte[] privKeyBytes = privKey.toBytes();
@@ -193,7 +193,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
byte[] privKeyBytes = privKey.toBytes(); byte[] privKeyBytes = privKey.toBytes();
@@ -233,7 +233,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
byte[] pubKeyBytes = pubKey.toBytes(); byte[] pubKeyBytes = pubKey.toBytes();
@@ -258,7 +258,7 @@ public class ED25519SignatureFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
byte[] pubKeyBytes = pubKey.toBytes(); byte[] pubKeyBytes = pubKey.toBytes();
@@ -304,7 +304,7 @@ public class ED25519SignatureFunctionTest {
SignatureFunction signatureFunction = SignatureFunction signatureFunction =
CryptoServiceProviders.getSignatureFunction(algorithm); CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();


@@ -335,7 +335,7 @@ public class ED25519SignatureFunctionTest {
SignatureFunction signatureFunction = SignatureFunction signatureFunction =
CryptoServiceProviders.getSignatureFunction(algorithm); CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();




+ 1
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricEncryptionFunction.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.crypto; package com.jd.blockchain.crypto;


public interface AsymmetricEncryptionFunction extends CryptoKeyPairGenerator, CryptoFunction {
public interface AsymmetricEncryptionFunction extends AsymmetricKeypairGenerator, CryptoFunction {


/** /**
* 加密; * 加密;


source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPair.java → source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypair.java View File

@@ -1,6 +1,12 @@
package com.jd.blockchain.crypto; package com.jd.blockchain.crypto;


public class CryptoKeyPair {
/**
* 非对称密钥对;
*
* @author huanghaiquan
*
*/
public class AsymmetricKeypair {


private PubKey pubKey; private PubKey pubKey;


@@ -18,7 +24,7 @@ public class CryptoKeyPair {
return privKey; return privKey;
} }


public CryptoKeyPair(PubKey pubKey, PrivKey privKey) {
public AsymmetricKeypair(PubKey pubKey, PrivKey privKey) {
if (pubKey.getAlgorithm() != privKey.getAlgorithm()) { if (pubKey.getAlgorithm() != privKey.getAlgorithm()) {
throw new IllegalArgumentException("The algorithms of PubKey and PrivKey don't match!"); throw new IllegalArgumentException("The algorithms of PubKey and PrivKey don't match!");
} }

+ 10
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/AsymmetricKeypairGenerator.java View File

@@ -0,0 +1,10 @@
package com.jd.blockchain.crypto;

public interface AsymmetricKeypairGenerator {

/**
* 返回密钥对;
*/
AsymmetricKeypair generateKeypair();

}

+ 0
- 10
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoKeyPairGenerator.java View File

@@ -1,10 +0,0 @@
package com.jd.blockchain.crypto;

public interface CryptoKeyPairGenerator {

/**
* 返回密钥对;
*/
CryptoKeyPair generateKeyPair();

}

+ 0
- 9
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoSymmetricKeyGenerator.java View File

@@ -1,9 +0,0 @@
package com.jd.blockchain.crypto;

public interface CryptoSymmetricKeyGenerator {

/**
* 返回对称密钥;
*/
CryptoKey generateSymmetricKey();
}

+ 1
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SignatureFunction.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.crypto; package com.jd.blockchain.crypto;


public interface SignatureFunction extends CryptoKeyPairGenerator, CryptoFunction {
public interface SignatureFunction extends AsymmetricKeypairGenerator, CryptoFunction {


/** /**
* 计算指定数据的 hash; * 计算指定数据的 hash;


+ 1
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricEncryptionFunction.java View File

@@ -3,7 +3,7 @@ package com.jd.blockchain.crypto;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;


public interface SymmetricEncryptionFunction extends CryptoSymmetricKeyGenerator, CryptoFunction {
public interface SymmetricEncryptionFunction extends SymmetricKeyGenerator, CryptoFunction {


/** /**
* 加密; * 加密;


+ 1
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKey.java View File

@@ -3,7 +3,7 @@ package com.jd.blockchain.crypto;
import static com.jd.blockchain.crypto.CryptoKeyType.SYMMETRIC; import static com.jd.blockchain.crypto.CryptoKeyType.SYMMETRIC;


/** /**
* 密钥;
* 对称密钥;
* *
* @author huanghaiquan * @author huanghaiquan
* *


+ 9
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/SymmetricKeyGenerator.java View File

@@ -0,0 +1,9 @@
package com.jd.blockchain.crypto;

public interface SymmetricKeyGenerator {

/**
* 返回对称密钥;
*/
SymmetricKey generateSymmetricKey();
}

+ 3
- 3
source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM2CryptoFunction.java View File

@@ -14,7 +14,7 @@ import com.jd.blockchain.crypto.AsymmetricEncryptionFunction;
import com.jd.blockchain.crypto.Ciphertext; import com.jd.blockchain.crypto.Ciphertext;
import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoAlgorithm;
import com.jd.blockchain.crypto.CryptoException; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -210,7 +210,7 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur
} }


@Override @Override
public CryptoKeyPair generateKeyPair() {
public AsymmetricKeypair generateKeypair() {


// 调用SM2算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 // 调用SM2算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对
AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair(); AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair();
@@ -230,6 +230,6 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur


byte[] pubKeyBytes = ecPub.getQ().getEncoded(false); 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));
} }
} }

+ 1
- 1
source/crypto/crypto-sm/src/main/java/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunction.java View File

@@ -205,7 +205,7 @@ public class SM4EncryptionFunction implements SymmetricEncryptionFunction {
} }


@Override @Override
public CryptoKey generateSymmetricKey() {
public SymmetricKey generateSymmetricKey() {
// 根据对应的标识和原始密钥生成相应的密钥数据 // 根据对应的标识和原始密钥生成相应的密钥数据
return new SymmetricKey(SM4, SM4Utils.generateKey()); return new SymmetricKey(SM4, SM4Utils.generateKey());
} }


+ 14
- 14
source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java View File

@@ -49,7 +49,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -82,7 +82,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -107,7 +107,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
SignatureDigest signatureDigest = signatureFunction.sign(privKey, data); SignatureDigest signatureDigest = signatureFunction.sign(privKey, data);
@@ -137,7 +137,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -159,7 +159,7 @@ public class SM2CyptoFunctionTest {
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders
.getAsymmetricEncryptionFunction(algorithm); .getAsymmetricEncryptionFunction(algorithm);


CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair();
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();


@@ -190,7 +190,7 @@ public class SM2CyptoFunctionTest {
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders
.getAsymmetricEncryptionFunction(algorithm); .getAsymmetricEncryptionFunction(algorithm);


CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair();
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
@@ -210,7 +210,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
byte[] privKeyBytes = privKey.toBytes(); byte[] privKeyBytes = privKey.toBytes();
@@ -235,7 +235,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
byte[] privKeyBytes = privKey.toBytes(); byte[] privKeyBytes = privKey.toBytes();
@@ -275,7 +275,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
byte[] pubKeyBytes = pubKey.toBytes(); byte[] pubKeyBytes = pubKey.toBytes();
@@ -300,7 +300,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();
byte[] pubKeyBytes = pubKey.toBytes(); byte[] pubKeyBytes = pubKey.toBytes();
@@ -344,7 +344,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();


@@ -374,7 +374,7 @@ public class SM2CyptoFunctionTest {


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm);


CryptoKeyPair keyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair keyPair = signatureFunction.generateKeypair();


PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();


@@ -420,7 +420,7 @@ public class SM2CyptoFunctionTest {
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders
.getAsymmetricEncryptionFunction(algorithm); .getAsymmetricEncryptionFunction(algorithm);


CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair();
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();


@@ -452,7 +452,7 @@ public class SM2CyptoFunctionTest {
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders
.getAsymmetricEncryptionFunction(algorithm); .getAsymmetricEncryptionFunction(algorithm);


CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair();
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair();


PubKey pubKey = keyPair.getPubKey(); PubKey pubKey = keyPair.getPubKey();




+ 3
- 3
source/gateway/src/main/java/com/jd/blockchain/gateway/GatewayServerBooter.java View File

@@ -11,7 +11,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.ClassPathResource; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.tools.keygen.KeyGenCommand; import com.jd.blockchain.tools.keygen.KeyGenCommand;
@@ -80,7 +80,7 @@ public class GatewayServerBooter {
private volatile ConfigurableApplicationContext appCtx; private volatile ConfigurableApplicationContext appCtx;
private GatewayConfigProperties config; private GatewayConfigProperties config;
private CryptoKeyPair defaultKeyPair;
private AsymmetricKeypair defaultKeyPair;
private String springConfigLocation; private String springConfigLocation;
public GatewayServerBooter(GatewayConfigProperties config, String springConfigLocation) { public GatewayServerBooter(GatewayConfigProperties config, String springConfigLocation) {
this.config = config; this.config = config;
@@ -102,7 +102,7 @@ public class GatewayServerBooter {
} else { } else {
privKey = KeyGenCommand.decodePrivKey(base58PrivKey, base58Pwd); privKey = KeyGenCommand.decodePrivKey(base58PrivKey, base58Pwd);
} }
defaultKeyPair = new CryptoKeyPair(pubKey, privKey);
defaultKeyPair = new AsymmetricKeypair(pubKey, privKey);
} }
public synchronized void start() { public synchronized void start() {


+ 2
- 2
source/gateway/src/main/java/com/jd/blockchain/gateway/PeerConnector.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.gateway; 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 com.jd.blockchain.utils.net.NetworkAddress;


import java.util.List; import java.util.List;
@@ -11,7 +11,7 @@ public interface PeerConnector {
boolean isConnected(); boolean isConnected();
void connect(NetworkAddress peerAddress, CryptoKeyPair defaultKeyPair, List<String> peerProviders);
void connect(NetworkAddress peerAddress, AsymmetricKeypair defaultKeyPair, List<String> peerProviders);


void reconnect(); void reconnect();


+ 4
- 4
source/gateway/src/main/java/com/jd/blockchain/gateway/service/PeerConnectionManager.java View File

@@ -4,7 +4,7 @@ import javax.annotation.PreDestroy;


import org.springframework.stereotype.Component; 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.PeerConnector;
import com.jd.blockchain.gateway.PeerService; import com.jd.blockchain.gateway.PeerService;
import com.jd.blockchain.ledger.data.TransactionService; import com.jd.blockchain.ledger.data.TransactionService;
@@ -21,7 +21,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector {


private volatile NetworkAddress peerAddress; private volatile NetworkAddress peerAddress;


private volatile CryptoKeyPair gateWayKeyPair;
private volatile AsymmetricKeypair gateWayKeyPair;


private volatile List<String> peerProviders; private volatile List<String> peerProviders;


@@ -36,7 +36,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector {
} }


@Override @Override
public synchronized void connect(NetworkAddress peerAddress, CryptoKeyPair defaultKeyPair, List<String> peerProviders) {
public synchronized void connect(NetworkAddress peerAddress, AsymmetricKeypair defaultKeyPair, List<String> peerProviders) {
if (isConnected()) { if (isConnected()) {
if (this.peerAddress.equals(peerAddress)) { if (this.peerAddress.equals(peerAddress)) {
return; return;
@@ -98,7 +98,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector {
this.peerAddress = peerAddress; this.peerAddress = peerAddress;
} }


public void setGateWayKeyPair(CryptoKeyPair gateWayKeyPair) {
public void setGateWayKeyPair(AsymmetricKeypair gateWayKeyPair) {
this.gateWayKeyPair = gateWayKeyPair; this.gateWayKeyPair = gateWayKeyPair;
} }




+ 4
- 4
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerEditerTest.java View File

@@ -9,7 +9,7 @@ import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.crypto.AddressEncoding; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
import com.jd.blockchain.crypto.service.classic.ClassicCryptoService; import com.jd.blockchain.crypto.service.classic.ClassicCryptoService;
@@ -57,7 +57,7 @@ public class LedgerEditerTest {
LedgerTransactionContext txCtx = ldgEdt.newTransaction(genesisTxReq); LedgerTransactionContext txCtx = ldgEdt.newTransaction(genesisTxReq);
LedgerDataSet ldgDS = txCtx.getDataSet(); LedgerDataSet ldgDS = txCtx.getDataSet();


CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair();


@Test @Test
public void testWriteDataAccoutKvOp() { public void testWriteDataAccoutKvOp() {
@@ -121,7 +121,7 @@ public class LedgerEditerTest {
parties[0] = new ConsensusParticipantData(); parties[0] = new ConsensusParticipantData();
parties[0].setId(0); parties[0].setId(0);
parties[0].setName("John"); parties[0].setName("John");
CryptoKeyPair kp0 = signFunc.generateKeyPair();
AsymmetricKeypair kp0 = signFunc.generateKeypair();
parties[0].setPubKey(kp0.getPubKey()); parties[0].setPubKey(kp0.getPubKey());
parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58());
parties[0].setHostAddress(new NetworkAddress("192.168.1.6", 9000)); parties[0].setHostAddress(new NetworkAddress("192.168.1.6", 9000));
@@ -129,7 +129,7 @@ public class LedgerEditerTest {
parties[1] = new ConsensusParticipantData(); parties[1] = new ConsensusParticipantData();
parties[1].setId(1); parties[1].setId(1);
parties[1].setName("John"); parties[1].setName("John");
CryptoKeyPair kp1 = signFunc.generateKeyPair();
AsymmetricKeypair kp1 = signFunc.generateKeypair();
parties[1].setPubKey(kp1.getPubKey()); parties[1].setPubKey(kp1.getPubKey());
parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58());
parties[1].setHostAddress(new NetworkAddress("192.168.1.7", 9000)); parties[1].setHostAddress(new NetworkAddress("192.168.1.7", 9000));


+ 5
- 5
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerManagerTest.java View File

@@ -11,7 +11,7 @@ import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.crypto.AddressEncoding; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -182,7 +182,7 @@ public class LedgerManagerTest {
parties[0] = new ConsensusParticipantData(); parties[0] = new ConsensusParticipantData();
parties[0].setId(0); parties[0].setId(0);
parties[0].setName("John"); parties[0].setName("John");
CryptoKeyPair kp0 = signatureFunction.generateKeyPair();
AsymmetricKeypair kp0 = signatureFunction.generateKeypair();
parties[0].setPubKey(kp0.getPubKey()); parties[0].setPubKey(kp0.getPubKey());
parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58());
parties[0].setHostAddress(new NetworkAddress("127.0.0.1", 9000)); parties[0].setHostAddress(new NetworkAddress("127.0.0.1", 9000));
@@ -190,7 +190,7 @@ public class LedgerManagerTest {
parties[1] = new ConsensusParticipantData(); parties[1] = new ConsensusParticipantData();
parties[1].setId(1); parties[1].setId(1);
parties[1].setName("Mary"); parties[1].setName("Mary");
CryptoKeyPair kp1 = signatureFunction.generateKeyPair();
AsymmetricKeypair kp1 = signatureFunction.generateKeypair();
parties[1].setPubKey(kp1.getPubKey()); parties[1].setPubKey(kp1.getPubKey());
parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58());
parties[1].setHostAddress(new NetworkAddress("127.0.0.1", 9010)); parties[1].setHostAddress(new NetworkAddress("127.0.0.1", 9010));
@@ -198,7 +198,7 @@ public class LedgerManagerTest {
parties[2] = new ConsensusParticipantData(); parties[2] = new ConsensusParticipantData();
parties[2].setId(2); parties[2].setId(2);
parties[2].setName("Jerry"); parties[2].setName("Jerry");
CryptoKeyPair kp2 = signatureFunction.generateKeyPair();
AsymmetricKeypair kp2 = signatureFunction.generateKeypair();
parties[2].setPubKey(kp2.getPubKey()); parties[2].setPubKey(kp2.getPubKey());
parties[2].setAddress(AddressEncoding.generateAddress(kp2.getPubKey()).toBase58()); parties[2].setAddress(AddressEncoding.generateAddress(kp2.getPubKey()).toBase58());
parties[2].setHostAddress(new NetworkAddress("127.0.0.1", 9020)); parties[2].setHostAddress(new NetworkAddress("127.0.0.1", 9020));
@@ -206,7 +206,7 @@ public class LedgerManagerTest {
parties[3] = new ConsensusParticipantData(); parties[3] = new ConsensusParticipantData();
parties[3].setId(3); parties[3].setId(3);
parties[3].setName("Tom"); parties[3].setName("Tom");
CryptoKeyPair kp3 = signatureFunction.generateKeyPair();
AsymmetricKeypair kp3 = signatureFunction.generateKeypair();
parties[3].setPubKey(kp3.getPubKey()); parties[3].setPubKey(kp3.getPubKey());
parties[3].setAddress(AddressEncoding.generateAddress(kp3.getPubKey()).toBase58()); parties[3].setAddress(AddressEncoding.generateAddress(kp3.getPubKey()).toBase58());
parties[3].setHostAddress(new NetworkAddress("127.0.0.1", 9030)); parties[3].setHostAddress(new NetworkAddress("127.0.0.1", 9030));


+ 3
- 3
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerTestUtils.java View File

@@ -2,7 +2,7 @@ package test.com.jd.blockchain.ledger;


import java.util.Random; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -34,7 +34,7 @@ public class LedgerTestUtils {


TxTemplate txTemp = new TxTemplate(ledgerHash, txHandle); TxTemplate txTemp = new TxTemplate(ledgerHash, txHandle);


CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair();
PubKey pubKey = cryptoKeyPair.getPubKey(); PubKey pubKey = cryptoKeyPair.getPubKey();
txTemp.users().register(new BlockchainIdentityData(pubKey)); txTemp.users().register(new BlockchainIdentityData(pubKey));
PreparedTransaction ptx = txTemp.prepare(); PreparedTransaction ptx = txTemp.prepare();
@@ -51,7 +51,7 @@ public class LedgerTestUtils {


txTemp.contractEvents().send(contractAddress, event, args); txTemp.contractEvents().send(contractAddress, event, args);


CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair();
PubKey pubKey = cryptoKeyPair.getPubKey(); PubKey pubKey = cryptoKeyPair.getPubKey();
txTemp.users().register(new BlockchainIdentityData(pubKey)); txTemp.users().register(new BlockchainIdentityData(pubKey));
PreparedTransaction ptx = txTemp.prepare(); PreparedTransaction ptx = txTemp.prepare();


+ 2
- 2
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyGenerator.java View File

@@ -1,7 +1,7 @@
package com.jd.blockchain.ledger; package com.jd.blockchain.ledger;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -33,7 +33,7 @@ public class BlockchainKeyGenerator {
public BlockchainKeyPair generate(CryptoAlgorithm signatureAlgorithm) { public BlockchainKeyPair generate(CryptoAlgorithm signatureAlgorithm) {
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction(signatureAlgorithm); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction(signatureAlgorithm);
CryptoKeyPair cryptoKeyPair = signFunc.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair();
return new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); return new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey());
} }


+ 2
- 2
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/BlockchainKeyPair.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.ledger; 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.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;
@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.Bytes;
* @author huanghaiquan * @author huanghaiquan
* *
*/ */
public class BlockchainKeyPair extends CryptoKeyPair {
public class BlockchainKeyPair extends AsymmetricKeypair {
private BlockchainIdentity id; private BlockchainIdentity id;


+ 2
- 2
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/PreparedTransaction.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.ledger; 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.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;


@@ -39,7 +39,7 @@ public interface PreparedTransaction extends HashObject {
* 签名账户的私钥; * 签名账户的私钥;
* @return * @return
*/ */
DigitalSignature sign(CryptoKeyPair keyPair);
DigitalSignature sign(AsymmetricKeypair keyPair);


/** /**
* 加入签名; * 加入签名;


+ 3
- 3
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionRequestBuilder.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.ledger; 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.HashDigest;
/** /**
@@ -38,7 +38,7 @@ public interface TransactionRequestBuilder extends HashObject {
* 签名账户的私钥; * 签名账户的私钥;
* @return * @return
*/ */
DigitalSignature signAsEndpoint(CryptoKeyPair keyPair);
DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair);
/** /**
* 对交易进行签名; * 对交易进行签名;
@@ -49,7 +49,7 @@ public interface TransactionRequestBuilder extends HashObject {
* 签名账户的私钥; * 签名账户的私钥;
* @return * @return
*/ */
DigitalSignature signAsNode(CryptoKeyPair keyPair);
DigitalSignature signAsNode(AsymmetricKeypair keyPair);
/** /**
* 加入签名; * 加入签名;


+ 2
- 2
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/PreparedTx.java View File

@@ -1,7 +1,7 @@
package com.jd.blockchain.ledger.data; package com.jd.blockchain.ledger.data;


import com.jd.blockchain.binaryproto.BinaryEncodingUtils; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -36,7 +36,7 @@ public class PreparedTx implements PreparedTransaction {
} }


@Override @Override
public DigitalSignature sign(CryptoKeyPair keyPair) {
public DigitalSignature sign(AsymmetricKeypair keyPair) {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(keyPair.getAlgorithm()); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(keyPair.getAlgorithm());
PrivKey privKey = keyPair.getPrivKey(); PrivKey privKey = keyPair.getPrivKey();
byte[] content = BinaryEncodingUtils.encode(getTransactionContent(), TransactionContent.class); byte[] content = BinaryEncodingUtils.encode(getTransactionContent(), TransactionContent.class);


+ 4
- 4
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/data/TxRequestBuilder.java View File

@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -41,14 +41,14 @@ public class TxRequestBuilder implements TransactionRequestBuilder {
} }
@Override @Override
public DigitalSignature signAsEndpoint(CryptoKeyPair keyPair) {
public DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair) {
DigitalSignature signature = sign(txContent, keyPair); DigitalSignature signature = sign(txContent, keyPair);
addEndpointSignature(signature); addEndpointSignature(signature);
return signature; return signature;
} }
@Override @Override
public DigitalSignature signAsNode(CryptoKeyPair keyPair) {
public DigitalSignature signAsNode(AsymmetricKeypair keyPair) {
DigitalSignature signature = sign(txContent, keyPair); DigitalSignature signature = sign(txContent, keyPair);
addNodeSignature(signature); addNodeSignature(signature);
return signature; return signature;
@@ -64,7 +64,7 @@ public class TxRequestBuilder implements TransactionRequestBuilder {
endpointSignatures.add(signature); 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()); SignatureDigest signatureDigest = sign(txContent, keyPair.getPrivKey());
DigitalSignature signature = new DigitalSignatureBlob(keyPair.getPubKey(), signatureDigest); DigitalSignature signature = new DigitalSignatureBlob(keyPair.getPubKey(), signatureDigest);
return signature; return signature;


+ 1
- 1
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ContractCodeDeployOpTemplateTest.java View File

@@ -43,7 +43,7 @@ public class ContractCodeDeployOpTemplateTest {
DataContractRegistry.register(ContractCodeDeployOperation.class); DataContractRegistry.register(ContractCodeDeployOperation.class);
DataContractRegistry.register(Operation.class); DataContractRegistry.register(Operation.class);
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519");
PubKey pubKey = signFunc.generateKeyPair().getPubKey();
PubKey pubKey = signFunc.generateKeypair().getPubKey();
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey);
byte[] chainCode = "jd-test".getBytes(); byte[] chainCode = "jd-test".getBytes();
data = new ContractCodeDeployOpTemplate(contractID, chainCode); data = new ContractCodeDeployOpTemplate(contractID, chainCode);


+ 1
- 1
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DataAccountRegisterOpTemplateTest.java View File

@@ -40,7 +40,7 @@ public class DataAccountRegisterOpTemplateTest {
DataContractRegistry.register(DataAccountRegisterOperation.class); DataContractRegistry.register(DataAccountRegisterOperation.class);
DataContractRegistry.register(Operation.class); DataContractRegistry.register(Operation.class);
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519");
PubKey pubKey = signFunc.generateKeyPair().getPubKey();
PubKey pubKey = signFunc.generateKeypair().getPubKey();
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey);
data = new DataAccountRegisterOpTemplate(contractID); data = new DataAccountRegisterOpTemplate(contractID);




+ 2
- 2
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/DigitalSignatureBlobTest.java View File

@@ -16,7 +16,7 @@ import org.junit.Test;
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.BinaryEncodingUtils;
import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -41,7 +41,7 @@ public class DigitalSignatureBlobTest {
DataContractRegistry.register(DigitalSignature.class); DataContractRegistry.register(DigitalSignature.class);
DataContractRegistry.register(DigitalSignatureBody.class); DataContractRegistry.register(DigitalSignatureBody.class);
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519");
CryptoKeyPair kp = signFunc.generateKeyPair();
AsymmetricKeypair kp = signFunc.generateKeypair();
PubKey pubKey = kp.getPubKey(); PubKey pubKey = kp.getPubKey();
SignatureDigest digest = signFunc.sign(kp.getPrivKey(), "zhangsan".getBytes()); SignatureDigest digest = signFunc.sign(kp.getPrivKey(), "zhangsan".getBytes());


+ 2
- 2
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java View File

@@ -4,7 +4,7 @@ import java.util.Random;


import org.junit.Test; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
import com.jd.blockchain.utils.security.Ed25519Utils; import com.jd.blockchain.utils.security.Ed25519Utils;
@@ -18,7 +18,7 @@ public class ED25519SignatureTest {
rand.nextBytes(data); rand.nextBytes(data);


SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519");
CryptoKeyPair key = signFunc.generateKeyPair();
AsymmetricKeypair key = signFunc.generateKeypair();
byte[] pubKey = key.getPubKey().getRawKeyBytes(); byte[] pubKey = key.getPubKey().getRawKeyBytes();
byte[] privKey = key.getPrivKey().getRawKeyBytes(); byte[] privKey = key.getPrivKey().getRawKeyBytes();




+ 5
- 5
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/TxRequestMessageTest.java View File

@@ -17,7 +17,7 @@ import org.junit.Test;


import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.BinaryEncodingUtils;
import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -60,10 +60,10 @@ public class TxRequestMessageTest {
data = new TxRequestMessage(initTransactionContent()); data = new TxRequestMessage(initTransactionContent());


SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); 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 digest1 = signFunc.sign(key1.getPrivKey(), "zhangsan".getBytes());
SignatureDigest digest2 = signFunc.sign(key2.getPrivKey(), "lisi".getBytes()); SignatureDigest digest2 = signFunc.sign(key2.getPrivKey(), "lisi".getBytes());


+ 2
- 2
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/UserRegisterOpTemplateTest.java View File

@@ -15,7 +15,7 @@ import org.junit.Test;


import com.jd.blockchain.binaryproto.BinaryEncodingUtils; import com.jd.blockchain.binaryproto.BinaryEncodingUtils;
import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.ledger.BlockchainIdentity; import com.jd.blockchain.ledger.BlockchainIdentity;
@@ -39,7 +39,7 @@ public class UserRegisterOpTemplateTest {
public void initUserRegisterOpTemplate() { public void initUserRegisterOpTemplate() {
DataContractRegistry.register(UserRegisterOperation.class); DataContractRegistry.register(UserRegisterOperation.class);
DataContractRegistry.register(Operation.class); DataContractRegistry.register(Operation.class);
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair();
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair();
PubKey pubKey = key.getPubKey(); PubKey pubKey = key.getPubKey();
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); BlockchainIdentity contractID = new BlockchainIdentityData(pubKey);
data = new UserRegisterOpTemplate(contractID); data = new UserRegisterOpTemplate(contractID);


+ 3
- 3
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java View File

@@ -5,7 +5,7 @@ import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.consensus.MessageService; import com.jd.blockchain.consensus.MessageService;
import com.jd.blockchain.consensus.client.ConsensusClient; import com.jd.blockchain.consensus.client.ConsensusClient;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -37,11 +37,11 @@ public class NodeSigningAppender implements TransactionService {


private ConsensusClient consensusClient; private ConsensusClient consensusClient;


private CryptoKeyPair nodeKeyPair;
private AsymmetricKeypair nodeKeyPair;
private CryptoAlgorithm hashAlgorithm; private CryptoAlgorithm hashAlgorithm;


public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, CryptoKeyPair nodeKeyPair, ConsensusClient consensusClient) {
public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, AsymmetricKeypair nodeKeyPair, ConsensusClient consensusClient) {
this.hashAlgorithm = hashAlgorithm; this.hashAlgorithm = hashAlgorithm;
this.nodeKeyPair = nodeKeyPair; this.nodeKeyPair = nodeKeyPair;
this.consensusClient = consensusClient; this.consensusClient = consensusClient;


+ 4
- 4
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/PeerBlockchainServiceFactory.java View File

@@ -4,7 +4,7 @@ import com.jd.blockchain.consensus.*;
import com.jd.blockchain.consensus.client.ClientFactory; import com.jd.blockchain.consensus.client.ClientFactory;
import com.jd.blockchain.consensus.client.ClientSettings; import com.jd.blockchain.consensus.client.ClientSettings;
import com.jd.blockchain.consensus.client.ConsensusClient; 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.crypto.HashDigest;
import com.jd.blockchain.ledger.CryptoSetting; import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.ledger.data.TransactionService; import com.jd.blockchain.ledger.data.TransactionService;
@@ -88,7 +88,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C
* *
* @return 区块链服务工厂实例; * @return 区块链服务工厂实例;
*/ */
public static PeerBlockchainServiceFactory connect(CryptoKeyPair gatewayKey, NetworkAddress peerAddr, List<String> peerProviders) {
public static PeerBlockchainServiceFactory connect(AsymmetricKeypair gatewayKey, NetworkAddress peerAddr, List<String> peerProviders) {


if (peerProviders == null || peerProviders.isEmpty()) { if (peerProviders == null || peerProviders.isEmpty()) {
throw new AuthenticationException("No peer Provider was set!"); throw new AuthenticationException("No peer Provider was set!");
@@ -245,7 +245,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C
* @param cryptoSetting * @param cryptoSetting
* @return * @return
*/ */
private static TransactionService enableGatewayAutoSigning(CryptoKeyPair nodeKeyPair, CryptoSetting cryptoSetting,
private static TransactionService enableGatewayAutoSigning(AsymmetricKeypair nodeKeyPair, CryptoSetting cryptoSetting,
ConsensusClient consensusClient) { ConsensusClient consensusClient) {
NodeSigningAppender signingAppender = new NodeSigningAppender(cryptoSetting.getHashAlgorithm(), NodeSigningAppender signingAppender = new NodeSigningAppender(cryptoSetting.getHashAlgorithm(),
nodeKeyPair, consensusClient); nodeKeyPair, consensusClient);
@@ -265,7 +265,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C
} }
} }


private static ClientIdentificationsProvider authIdProvider(CryptoKeyPair gatewayKey, List<String> peerProviders) {
private static ClientIdentificationsProvider authIdProvider(AsymmetricKeypair gatewayKey, List<String> peerProviders) {
ClientIdentificationsProvider authIdProvider = new ClientIdentificationsProvider(); ClientIdentificationsProvider authIdProvider = new ClientIdentificationsProvider();
for (String peerProvider : peerProviders) { for (String peerProvider : peerProviders) {
ConsensusProvider provider = ConsensusProviders.getProvider(peerProvider); ConsensusProvider provider = ConsensusProviders.getProvider(peerProvider);


+ 4
- 4
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_Contract.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.sdk.samples; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -88,7 +88,7 @@ public class SDKDemo_Contract {
String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); String txHash = ByteArray.toBase64(prepTx.getHash().toBytes());


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -107,9 +107,9 @@ public class SDKDemo_Contract {
* *
* @return * @return
*/ */
private static CryptoKeyPair getSponsorKey() {
private static AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }


/** /**


+ 4
- 4
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_DataAccount.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.sdk.samples; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -61,7 +61,7 @@ public class SDKDemo_DataAccount {
PreparedTransaction prepTx = txTemp.prepare(); PreparedTransaction prepTx = txTemp.prepare();


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -73,9 +73,9 @@ public class SDKDemo_DataAccount {
return null; return null;
} }


private static CryptoKeyPair getSponsorKey() {
private static AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }


} }

+ 4
- 4
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_InsertData.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.sdk.samples; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -67,7 +67,7 @@ public class SDKDemo_InsertData {
String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); String txHash = ByteArray.toBase64(prepTx.getHash().toBytes());


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -79,9 +79,9 @@ public class SDKDemo_InsertData {
return null; return null;
} }


private static CryptoKeyPair getSponsorKey() {
private static AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }


/** /**


+ 2
- 2
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterAccount.java View File

@@ -1,7 +1,7 @@
package com.jd.blockchain.sdk.samples; package com.jd.blockchain.sdk.samples;
import com.jd.blockchain.binaryproto.DataContractRegistry; 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.HashDigest;
import com.jd.blockchain.ledger.*; import com.jd.blockchain.ledger.*;
import com.jd.blockchain.sdk.BlockchainService; import com.jd.blockchain.sdk.BlockchainService;
@@ -37,7 +37,7 @@ public class SDKDemo_RegisterAccount {
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]);
//existed signer //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(); BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate();


+ 1
- 1
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterTest.java View File

@@ -9,7 +9,7 @@
package com.jd.blockchain.sdk.samples; package com.jd.blockchain.sdk.samples;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;


+ 2
- 2
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_RegisterUser.java View File

@@ -9,7 +9,7 @@
package com.jd.blockchain.sdk.samples; package com.jd.blockchain.sdk.samples;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -58,7 +58,7 @@ public class SDKDemo_RegisterUser {
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]);


//existed signer //existed signer
CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey);
AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey);


BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate();




+ 5
- 5
source/sdk/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDKDemo_User.java View File

@@ -1,6 +1,6 @@
package com.jd.blockchain.sdk.samples; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
@@ -64,7 +64,7 @@ public class SDKDemo_User {
//BlockchainKeyPair user = generator.generate(CryptoKeyType.PUBLIC); //BlockchainKeyPair user = generator.generate(CryptoKeyType.PUBLIC);


SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair();
BlockchainKeyPair user = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); BlockchainKeyPair user = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey());


txTemp.users().register(user.getIdentity()); txTemp.users().register(user.getIdentity());
@@ -75,7 +75,7 @@ public class SDKDemo_User {
PreparedTransaction prepTx = txTemp.prepare(); PreparedTransaction prepTx = txTemp.prepare();


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -87,9 +87,9 @@ public class SDKDemo_User {
return null; return null;
} }


private static CryptoKeyPair getSponsorKey() {
private static AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }


} }

+ 4
- 4
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_BatchInsertData_Test_.java View File

@@ -14,7 +14,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -99,7 +99,7 @@ public class SDK_GateWay_BatchInsertData_Test_ {
PreparedTransaction prepTx = txTemp.prepare(); PreparedTransaction prepTx = txTemp.prepare();


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -123,9 +123,9 @@ public class SDK_GateWay_BatchInsertData_Test_ {
} }




private CryptoKeyPair getSponsorKey() {
private AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }
private TransactionResponse initResponse() { private TransactionResponse initResponse() {


+ 4
- 4
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_DataAccount_Test_.java View File

@@ -12,7 +12,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -81,7 +81,7 @@ public class SDK_GateWay_DataAccount_Test_ {
// CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); // CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();


//existed signer //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(); BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate();


@@ -118,8 +118,8 @@ public class SDK_GateWay_DataAccount_Test_ {
return CryptoServiceProviders.getSignatureFunction("ED25519"); return CryptoServiceProviders.getSignatureFunction("ED25519");
} }


private CryptoKeyPair getSponsorKey() {
return getSignatureFunction().generateKeyPair();
private AsymmetricKeypair getSponsorKey() {
return getSignatureFunction().generateKeypair();
} }


private TransactionResponse initResponse() { private TransactionResponse initResponse() {


+ 4
- 4
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_InsertData_Test_.java View File

@@ -14,7 +14,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -92,7 +92,7 @@ public class SDK_GateWay_InsertData_Test_ {
PreparedTransaction prepTx = txTemp.prepare(); PreparedTransaction prepTx = txTemp.prepare();


// 使用私钥进行签名; // 使用私钥进行签名;
CryptoKeyPair keyPair = getSponsorKey();
AsymmetricKeypair keyPair = getSponsorKey();
prepTx.sign(keyPair); prepTx.sign(keyPair);


// 提交交易; // 提交交易;
@@ -117,9 +117,9 @@ public class SDK_GateWay_InsertData_Test_ {
} }




private CryptoKeyPair getSponsorKey() {
private AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }
private TransactionResponse initResponse() { private TransactionResponse initResponse() {


+ 2
- 2
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java View File

@@ -12,7 +12,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -186,7 +186,7 @@ public class SDK_GateWay_Query_Test_ {


private BlockchainKeyPair getSponsorKey() { private BlockchainKeyPair getSponsorKey() {
SignatureFunction signatureFunction = getSignatureFunction(); SignatureFunction signatureFunction = getSignatureFunction();
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair();
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair();
BlockchainKeyPair blockchainKeyPair = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), BlockchainKeyPair blockchainKeyPair = new BlockchainKeyPair(cryptoKeyPair.getPubKey(),
cryptoKeyPair.getPrivKey()); cryptoKeyPair.getPrivKey());
return blockchainKeyPair; return blockchainKeyPair;


+ 4
- 4
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_User_Test_.java View File

@@ -14,7 +14,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.binaryproto.DataContractRegistry; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
@@ -103,7 +103,7 @@ public class SDK_GateWay_User_Test_ {
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]);


//existed signer //existed signer
CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey);
AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey);


BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate();


@@ -137,9 +137,9 @@ public class SDK_GateWay_User_Test_ {
// return new HashDigest(hashBytes); // return new HashDigest(hashBytes);
// } // }


private CryptoKeyPair getSponsorKey() {
private AsymmetricKeypair getSponsorKey() {
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519");
return signatureFunction.generateKeyPair();
return signatureFunction.generateKeypair();
} }


private TransactionResponse initResponse() { private TransactionResponse initResponse() {


+ 4
- 4
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegratedContext.java View File

@@ -5,7 +5,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;


import com.jd.blockchain.consensus.ConsensusSettings; 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.ledger.core.impl.LedgerManager;
import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory; import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory;
import com.jd.blockchain.tools.initializer.LedgerBindingConfig; import com.jd.blockchain.tools.initializer.LedgerBindingConfig;
@@ -37,7 +37,7 @@ public class IntegratedContext {


private int id; private int id;


private CryptoKeyPair partiKeyPair;
private AsymmetricKeypair partiKeyPair;


// private NetworkAddress consensusAddress; // private NetworkAddress consensusAddress;
private ConsensusSettings consensusSettings; private ConsensusSettings consensusSettings;
@@ -64,11 +64,11 @@ public class IntegratedContext {
return storageDB; return storageDB;
} }


public CryptoKeyPair getPartiKeyPair() {
public AsymmetricKeypair getPartiKeyPair() {
return partiKeyPair; return partiKeyPair;
} }


public void setPartiKeyPair(CryptoKeyPair partiKeyPair) {
public void setPartiKeyPair(AsymmetricKeypair partiKeyPair) {
this.partiKeyPair = partiKeyPair; this.partiKeyPair = partiKeyPair;
} }




+ 14
- 14
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/IntegrationTest.java View File

@@ -14,7 +14,7 @@ import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.AddressEncoding; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -169,7 +169,7 @@ public class IntegrationTest {


HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); 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); 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) { String dataAccountAddress, IntegratedContext context) {


// 在本地定义注册账号的 TX; // 在本地定义注册账号的 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) { BlockchainService blockchainService, IntegratedContext context) {
// 注册用户,并验证最终写入; // 注册用户,并验证最终写入;
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate();
@@ -253,7 +253,7 @@ public class IntegrationTest {
return user; return user;
} }


private BlockchainKeyPair testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash,
private BlockchainKeyPair testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash,
BlockchainService blockchainService, IntegratedContext context) { BlockchainService blockchainService, IntegratedContext context) {
// 注册数据账户,并验证最终写入; // 注册数据账户,并验证最终写入;
BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate();
@@ -286,7 +286,7 @@ public class IntegrationTest {
return dataAccount; 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) { IntegratedContext context, BlockchainKeyPair newUserAcount, BlockchainKeyPair newDataAcount) {


Bytes userAddress = newUserAcount.getAddress(); Bytes userAddress = newUserAcount.getAddress();
@@ -501,7 +501,7 @@ public class IntegrationTest {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -509,7 +509,7 @@ public class IntegrationTest {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -517,7 +517,7 @@ public class IntegrationTest {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -525,7 +525,7 @@ public class IntegrationTest {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); 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) { BlockchainService blockchainService, IntegratedContext context) {
// valid the basic data in contract; // valid the basic data in contract;
prepareContractData(adminKey, ledgerHash, blockchainService, context); prepareContractData(adminKey, ledgerHash, blockchainService, context);
@@ -585,7 +585,7 @@ public class IntegrationTest {
return block; return block;
} }


private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
BlockchainService blockchainService, IntegratedContext context) { BlockchainService blockchainService, IntegratedContext context) {
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash);
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1);
@@ -616,7 +616,7 @@ public class IntegrationTest {


// 验证合约中的赋值,外部可以获得; // 验证合约中的赋值,外部可以获得;
DataAccountSet dataAccountSet = ledgerOfNode0.getDataAccountSet(backgroundLedgerBlock); DataAccountSet dataAccountSet = ledgerOfNode0.getDataAccountSet(backgroundLedgerBlock);
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair();
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair();
PubKey pubKey = key.getPubKey(); PubKey pubKey = key.getPubKey();
Bytes dataAddress = AddressEncoding.generateAddress(pubKey); Bytes dataAddress = AddressEncoding.generateAddress(pubKey);


@@ -629,7 +629,7 @@ public class IntegrationTest {
// assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); // 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) { IntegratedContext context) {


// 定义交易; // 定义交易;


+ 6
- 6
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/consensus/ConsensusTest.java View File

@@ -14,7 +14,7 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -162,7 +162,7 @@ public class ConsensusTest {
} }


private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, 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]; PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length];
for (int i = 0; i < ptxs.length; i++) { for (int i = 0; i < ptxs.length; i++) {
// 定义交易; // 定义交易;
@@ -252,7 +252,7 @@ public class ConsensusTest {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -260,7 +260,7 @@ public class ConsensusTest {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -268,7 +268,7 @@ public class ConsensusTest {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -276,7 +276,7 @@ public class ConsensusTest {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); context.addNode(node3);




+ 6
- 6
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/GlobalPerformanceTest.java View File

@@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
@@ -160,7 +160,7 @@ public class GlobalPerformanceTest {
} }


private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, 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]; PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length];
for (int i = 0; i < ptxs.length; i++) { for (int i = 0; i < ptxs.length; i++) {
// 定义交易; // 定义交易;
@@ -250,7 +250,7 @@ public class GlobalPerformanceTest {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -258,7 +258,7 @@ public class GlobalPerformanceTest {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -266,7 +266,7 @@ public class GlobalPerformanceTest {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -274,7 +274,7 @@ public class GlobalPerformanceTest {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); context.addNode(node3);




+ 5
- 5
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerInitializeTest.java View File

@@ -12,7 +12,7 @@ import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.AddressEncoding; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -168,9 +168,9 @@ public class LedgerInitializeTest {


private LedgerInitProcess initProcess; private LedgerInitProcess initProcess;


private CryptoKeyPair partiKey;
private AsymmetricKeypair partiKey;


public CryptoKeyPair getPartiKey() {
public AsymmetricKeypair getPartiKey() {
return partiKey; return partiKey;
} }


@@ -198,7 +198,7 @@ public class LedgerInitializeTest {
ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig,
Prompter prompter) { Prompter prompter) {


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override
@@ -219,7 +219,7 @@ public class LedgerInitializeTest {
cryptoSetting.setAutoVerifyHash(autoVerifyHash); cryptoSetting.setAutoVerifyHash(autoVerifyHash);
cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256"));


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override


+ 8
- 8
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/LedgerPerformanceTest.java View File

@@ -17,7 +17,7 @@ import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -178,7 +178,7 @@ public class LedgerPerformanceTest {
* @param batchCount * @param batchCount
* @param silent * @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) { DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) {
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); LedgerRepository ledger = ledgerManager.getLedger(ledgerHash);
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [注册用户] ================="); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [注册用户] =================");
@@ -219,7 +219,7 @@ public class LedgerPerformanceTest {
* @param batchCount * @param batchCount
* @param silent * @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) { DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) {
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); LedgerRepository ledger = ledgerManager.getLedger(ledgerHash);
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [写入数据] ================="); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [写入数据] =================");
@@ -273,7 +273,7 @@ public class LedgerPerformanceTest {
* @param batchCount * @param batchCount
* @param silent * @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) { DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) {
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); LedgerRepository ledger = ledgerManager.getLedger(ledgerHash);
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [执行合约] ================="); ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [执行合约] =================");
@@ -356,7 +356,7 @@ public class LedgerPerformanceTest {
} }


public static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count, public static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count,
CryptoKeyPair adminKey) {
AsymmetricKeypair adminKey) {
long startTs = System.currentTimeMillis(); long startTs = System.currentTimeMillis();
List<TransactionRequest> txList = new ArrayList<>(); List<TransactionRequest> txList = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@@ -376,7 +376,7 @@ public class LedgerPerformanceTest {
} }


public static List<TransactionRequest> prepareDataAccountRegisterRequests(HashDigest ledgerHash, public static List<TransactionRequest> prepareDataAccountRegisterRequests(HashDigest ledgerHash,
BlockchainIdentity[] dataAccounts, CryptoKeyPair adminKey, boolean statistic) {
BlockchainIdentity[] dataAccounts, AsymmetricKeypair adminKey, boolean statistic) {
int count = dataAccounts.length; int count = dataAccounts.length;
long startTs = System.currentTimeMillis(); long startTs = System.currentTimeMillis();
List<TransactionRequest> txList = new ArrayList<>(); List<TransactionRequest> txList = new ArrayList<>();
@@ -400,7 +400,7 @@ public class LedgerPerformanceTest {
} }


public static List<TransactionRequest> prepareDataWriteRequests(HashDigest ledgerHash, public static List<TransactionRequest> prepareDataWriteRequests(HashDigest ledgerHash,
BlockchainIdentity[] dataAccounts, int count, CryptoKeyPair adminKey, boolean statistic) {
BlockchainIdentity[] dataAccounts, int count, AsymmetricKeypair adminKey, boolean statistic) {
long startTs = System.currentTimeMillis(); long startTs = System.currentTimeMillis();
List<TransactionRequest> txList = new ArrayList<>(); List<TransactionRequest> txList = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@@ -428,7 +428,7 @@ public class LedgerPerformanceTest {
return ConsensusProviders.getProvider(provider); return ConsensusProviders.getProvider(provider);
} }
public static List<TransactionRequest> prepareContractRequests(HashDigest ledgerHash, public static List<TransactionRequest> prepareContractRequests(HashDigest ledgerHash,
CryptoKeyPair adminKey, int count, boolean statistic, TransactionBatchProcessor txProc) {
AsymmetricKeypair adminKey, int count, boolean statistic, TransactionBatchProcessor txProc) {


// deploy contract // deploy contract
byte[] chainCode; byte[] chainCode;


+ 5
- 5
source/test/test-integration/src/main/java/test/com/jd/blockchain/intgr/perf/Utils.java View File

@@ -11,7 +11,7 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -81,9 +81,9 @@ public class Utils {


private LedgerInitProcess initProcess; private LedgerInitProcess initProcess;


private CryptoKeyPair partiKey;
private AsymmetricKeypair partiKey;


public CryptoKeyPair getPartiKey() {
public AsymmetricKeypair getPartiKey() {
return partiKey; return partiKey;
} }


@@ -109,7 +109,7 @@ public class Utils {
ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig,
Prompter prompter) { Prompter prompter) {


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override
@@ -145,7 +145,7 @@ public class Utils {
ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig,
Prompter prompter, CryptoSetting cryptoSetting) { Prompter prompter, CryptoSetting cryptoSetting) {


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override


+ 6
- 6
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java View File

@@ -10,7 +10,7 @@ package test.com.jd.blockchain.intgr;


import com.jd.blockchain.binaryproto.DataContractRegistry; import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.crypto.AddressEncoding; 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.crypto.HashDigest;
import com.jd.blockchain.ledger.*; import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.LedgerManage; import com.jd.blockchain.ledger.core.LedgerManage;
@@ -73,7 +73,7 @@ public class IntegrationBase {


public static final AtomicLong validLong = new AtomicLong(); 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(); BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate();


@@ -98,7 +98,7 @@ public class IntegrationBase {
return keyPairResponse; 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(); BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate();


@@ -123,7 +123,7 @@ public class IntegrationBase {
return keyPairResponse; 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) { Bytes dataAccount) {


// 在本地定义注册账号的 TX; // 在本地定义注册账号的 TX;
@@ -440,7 +440,7 @@ public class IntegrationBase {
HashDigest txContentHash; HashDigest txContentHash;
String pubKeyVal = "jd.com"+System.currentTimeMillis(); String pubKeyVal = "jd.com"+System.currentTimeMillis();
private String eventName = "issue-asset"; 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) { BlockchainService blockchainService,LedgerRepository ledgerRepository) {
System.out.println("adminKey="+ AddressEncoding.generateAddress(adminKey.getPubKey())); System.out.println("adminKey="+ AddressEncoding.generateAddress(adminKey.getPubKey()));
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate();
@@ -475,7 +475,7 @@ public class IntegrationBase {
return block; return block;
} }


private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
BlockchainService blockchainService,LedgerRepository ledgerRepository) { BlockchainService blockchainService,LedgerRepository ledgerRepository) {
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash);
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1);


+ 5
- 5
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBaseTest.java View File

@@ -3,7 +3,7 @@ package test.com.jd.blockchain.intgr;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig;
@@ -197,7 +197,7 @@ public class IntegrationBaseTest {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -205,7 +205,7 @@ public class IntegrationBaseTest {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -213,7 +213,7 @@ public class IntegrationBaseTest {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -221,7 +221,7 @@ public class IntegrationBaseTest {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); context.addNode(node3);




+ 8
- 8
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest2.java View File

@@ -18,7 +18,7 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig;
@@ -150,7 +150,7 @@ public class IntegrationTest2 {


HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); HashDigest[] ledgerHashs = bcsrv.getLedgerHashs();


CryptoKeyPair adminKey = context.getNode(0).getPartiKeyPair();
AsymmetricKeypair adminKey = context.getNode(0).getPartiKeyPair();


testSDK_Contract(adminKey, ledgerHashs[0], bcsrv, context); testSDK_Contract(adminKey, ledgerHashs[0], bcsrv, context);


@@ -239,7 +239,7 @@ public class IntegrationTest2 {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -247,7 +247,7 @@ public class IntegrationTest2 {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -255,7 +255,7 @@ public class IntegrationTest2 {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -263,7 +263,7 @@ public class IntegrationTest2 {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); 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) { BlockchainService blockchainService, IntegratedContext context) {
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate();


@@ -307,7 +307,7 @@ public class IntegrationTest2 {
testContractExe(adminKey, ledgerHash, userKey, blockchainService, context); 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) { BlockchainService blockchainService, IntegratedContext context) {
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash);
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight()-1); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight()-1);


+ 2
- 2
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java View File

@@ -1,6 +1,6 @@
package test.com.jd.blockchain.intgr; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -101,7 +101,7 @@ public class IntegrationTest4Bftsmart {


PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]);


CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0);
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0);


BlockchainService blockchainService = gwsrvFact.getBlockchainService(); BlockchainService blockchainService = gwsrvFact.getBlockchainService();




+ 2
- 2
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java View File

@@ -1,6 +1,6 @@
package test.com.jd.blockchain.intgr; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -111,7 +111,7 @@ public class IntegrationTest4MQ {


PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]);


CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0);
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0);


BlockchainService blockchainService = gwsrvFact.getBlockchainService(); BlockchainService blockchainService = gwsrvFact.getBlockchainService();




+ 11
- 11
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java View File

@@ -15,7 +15,7 @@ import org.junit.Test;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;


import com.jd.blockchain.crypto.AddressEncoding; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -145,7 +145,7 @@ public class IntegrationTestAll4Redis {
PubKey pubKey2 = KeyGenCommand.decodePubKey(PUB_KEYS[2]); PubKey pubKey2 = KeyGenCommand.decodePubKey(PUB_KEYS[2]);
PubKey pubKey3 = KeyGenCommand.decodePubKey(PUB_KEYS[3]); PubKey pubKey3 = KeyGenCommand.decodePubKey(PUB_KEYS[3]);


CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0);
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0);


testWriteBatchTransactions(gateway0, adminKey, ledgers[0]); 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) { LedgerRepository ledgerRepository) {
// 连接网关; // 连接网关;
GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress());
@@ -257,7 +257,7 @@ public class IntegrationTestAll4Redis {
return; 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()); GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress());
BlockchainService bcsrv = gwsrvFact.getBlockchainService(); 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) { Bytes dataAccountAddress, LedgerRepository ledgerRepository) {


// 在本地定义注册账号的 TX; // 在本地定义注册账号的 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) { BlockchainService blockchainService, LedgerRepository ledgerRepository) {
// 注册数据账户,并验证最终写入; // 注册数据账户,并验证最终写入;
BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate();
@@ -350,7 +350,7 @@ public class IntegrationTestAll4Redis {
return dataAccount; return dataAccount;
} }


private BlockchainKeyPair testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash,
private BlockchainKeyPair testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash,
BlockchainService blockchainService, LedgerRepository ledgerRepository) { BlockchainService blockchainService, LedgerRepository ledgerRepository) {
// 注册用户,并验证最终写入; // 注册用户,并验证最终写入;
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); 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) { BlockchainService blockchainService, LedgerRepository ledgerRepository) {
System.out.println("adminKey=" + AddressEncoding.generateAddress(adminKey.getPubKey())); System.out.println("adminKey=" + AddressEncoding.generateAddress(adminKey.getPubKey()));
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate();
@@ -442,7 +442,7 @@ public class IntegrationTestAll4Redis {
return block; return block;
} }


private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey,
BlockchainService blockchainService, LedgerRepository ledgerRepository) { BlockchainService blockchainService, LedgerRepository ledgerRepository) {
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash);
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1);
@@ -474,7 +474,7 @@ public class IntegrationTestAll4Redis {


// 验证合约中的赋值,外部可以获得; // 验证合约中的赋值,外部可以获得;
DataAccountSet dataAccountSet = ledgerRepository.getDataAccountSet(backgroundLedgerBlock); DataAccountSet dataAccountSet = ledgerRepository.getDataAccountSet(backgroundLedgerBlock);
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair();
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair();
PubKey pubKey = key.getPubKey(); PubKey pubKey = key.getPubKey();
Bytes dataAddress = AddressEncoding.generateAddress(pubKey); Bytes dataAddress = AddressEncoding.generateAddress(pubKey);
assertEquals(dataAddress, dataAccountSet.getDataAccount(dataAddress).getAddress()); assertEquals(dataAddress, dataAccountSet.getDataAccount(dataAddress).getAddress());
@@ -489,7 +489,7 @@ public class IntegrationTestAll4Redis {
// assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); // 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) { LedgerRepository ledgerRepository) {


// 定义交易; // 定义交易;


+ 8
- 8
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestDataAccount.java View File

@@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSON;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -126,7 +126,7 @@ public class IntegrationTestDataAccount {
PrivKey privkey0 = KeyGenCommand.decodePrivKeyWithRawPassword(LedgerInitializeWeb4SingleStepsTest.PRIV_KEYS[0], PrivKey privkey0 = KeyGenCommand.decodePrivKeyWithRawPassword(LedgerInitializeWeb4SingleStepsTest.PRIV_KEYS[0],
LedgerInitializeWeb4SingleStepsTest.PASSWORD); LedgerInitializeWeb4SingleStepsTest.PASSWORD);
PubKey pubKey0 = KeyGenCommand.decodePubKey(LedgerInitializeWeb4SingleStepsTest.PUB_KEYS[0]); PubKey pubKey0 = KeyGenCommand.decodePubKey(LedgerInitializeWeb4SingleStepsTest.PUB_KEYS[0]);
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0);
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0);


// regist data account // regist data account
Bytes dataAddr = registDataAccount(gateway0, adminKey, context); Bytes dataAddr = registDataAccount(gateway0, adminKey, context);
@@ -138,7 +138,7 @@ public class IntegrationTestDataAccount {
testConsistencyAmongNodes(context); 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()); GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress());
BlockchainService blockchainService = gwsrvFact.getBlockchainService(); BlockchainService blockchainService = gwsrvFact.getBlockchainService();
@@ -173,7 +173,7 @@ public class IntegrationTestDataAccount {
} }


// 通过调用SDK->GATEWAY,测试一个区块包含多个交易时的写入情况,并验证写入结果; // 通过调用SDK->GATEWAY,测试一个区块包含多个交易时的写入情况,并验证写入结果;
private void testAddKvOpToDataAccount(GatewayTestRunner gateway, CryptoKeyPair adminKey, IntegratedContext context,
private void testAddKvOpToDataAccount(GatewayTestRunner gateway, AsymmetricKeypair adminKey, IntegratedContext context,
Bytes dataAddr) { Bytes dataAddr) {


GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress());
@@ -335,7 +335,7 @@ public class IntegrationTestDataAccount {
node0.setConsensusSettings(csProps); node0.setConsensusSettings(csProps);
node0.setLedgerManager(nodeCtx0.getLedgerManager()); node0.setLedgerManager(nodeCtx0.getLedgerManager());
node0.setStorageDB(nodeCtx0.getStorageDB()); 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); node0.setBindingConfig(bindingConfig0);
context.addNode(node0); context.addNode(node0);


@@ -343,7 +343,7 @@ public class IntegrationTestDataAccount {
node1.setConsensusSettings(csProps); node1.setConsensusSettings(csProps);
node1.setLedgerManager(nodeCtx1.getLedgerManager()); node1.setLedgerManager(nodeCtx1.getLedgerManager());
node1.setStorageDB(nodeCtx1.getStorageDB()); 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); node1.setBindingConfig(bindingConfig1);
context.addNode(node1); context.addNode(node1);


@@ -351,7 +351,7 @@ public class IntegrationTestDataAccount {
node2.setConsensusSettings(csProps); node2.setConsensusSettings(csProps);
node2.setLedgerManager(nodeCtx2.getLedgerManager()); node2.setLedgerManager(nodeCtx2.getLedgerManager());
node2.setStorageDB(nodeCtx2.getStorageDB()); 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); node2.setBindingConfig(bindingConfig2);
context.addNode(node2); context.addNode(node2);


@@ -359,7 +359,7 @@ public class IntegrationTestDataAccount {
node3.setConsensusSettings(csProps); node3.setConsensusSettings(csProps);
node3.setLedgerManager(nodeCtx3.getLedgerManager()); node3.setLedgerManager(nodeCtx3.getLedgerManager());
node3.setStorageDB(nodeCtx3.getStorageDB()); 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); node3.setBindingConfig(bindingConfig3);
context.addNode(node3); context.addNode(node3);




+ 2
- 2
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartLedgerInit.java View File

@@ -8,7 +8,7 @@
*/ */
package test.com.jd.blockchain.intgr.batch.bftsmart; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -181,7 +181,7 @@ public class BftsmartLedgerInit {


PubKey pubKey0 = KeyGenCommand.decodePubKey(BftsmartConfig.PUB_KEY[0]); PubKey pubKey0 = KeyGenCommand.decodePubKey(BftsmartConfig.PUB_KEY[0]);


CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0);
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0);


BlockchainService blockchainService = gwsrvFact.getBlockchainService(); BlockchainService blockchainService = gwsrvFact.getBlockchainService();




+ 2
- 2
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/batch/bftsmart/BftsmartTestBase.java View File

@@ -13,7 +13,7 @@ import static com.jd.blockchain.tools.keygen.KeyGenCommand.encodePubKey;


import org.junit.Test; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
import com.jd.blockchain.utils.codec.Base58Utils; import com.jd.blockchain.utils.codec.Base58Utils;
@@ -38,7 +38,7 @@ public class BftsmartTestBase {
public void newUsers() { public void newUsers() {
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519");
for (int i = 0; i < userSize; i++) { for (int i = 0; i < userSize; i++) {
CryptoKeyPair kp = signFunc.generateKeyPair();
AsymmetricKeypair kp = signFunc.generateKeypair();


String base58PubKey = encodePubKey(kp.getPubKey()); String base58PubKey = encodePubKey(kp.getPubKey());




+ 5
- 5
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitializeTest.java View File

@@ -19,7 +19,7 @@ import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.AddressEncoding; import com.jd.blockchain.crypto.AddressEncoding;
import com.jd.blockchain.crypto.CryptoAlgorithm; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
@@ -211,9 +211,9 @@ public class LedgerInitializeTest {


private LedgerInitProcess initProcess; private LedgerInitProcess initProcess;


private CryptoKeyPair partiKey;
private AsymmetricKeypair partiKey;


public CryptoKeyPair getPartiKey() {
public AsymmetricKeypair getPartiKey() {
return partiKey; return partiKey;
} }


@@ -237,7 +237,7 @@ public class LedgerInitializeTest {
ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig,
Prompter prompter) { Prompter prompter) {


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override
@@ -258,7 +258,7 @@ public class LedgerInitializeTest {
cryptoSetting.setAutoVerifyHash(autoVerifyHash); cryptoSetting.setAutoVerifyHash(autoVerifyHash);
cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256"));


partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey);
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey);


ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() {
@Override @Override


+ 3
- 3
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/ledger/LedgerBlockGeneratingTest.java View File

@@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource;
import com.jd.blockchain.consensus.ConsensusProvider; import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders; import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.ledger.BlockchainKeyGenerator; import com.jd.blockchain.ledger.BlockchainKeyGenerator;
@@ -63,7 +63,7 @@ public class LedgerBlockGeneratingTest {
test(ledgerHash, node.getPartiKey(), ledgerManager, opHandler, 1000, 5); 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) { DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount) {
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); LedgerRepository ledger = ledgerManager.getLedger(ledgerHash);
long height = ledger.getLatestBlockHeight(); long height = ledger.getLatestBlockHeight();
@@ -106,7 +106,7 @@ public class LedgerBlockGeneratingTest {
} }


private static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count, private static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count,
CryptoKeyPair adminKey) {
AsymmetricKeypair adminKey) {
List<TransactionRequest> txList = new ArrayList<>(); List<TransactionRequest> txList = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
TxBuilder txbuilder = new TxBuilder(ledgerHash); TxBuilder txbuilder = new TxBuilder(ledgerHash);


+ 5
- 5
source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/RemoteTransactionService.java View File

@@ -21,7 +21,7 @@ import com.jd.blockchain.binaryproto.BinaryEncodingUtils;
import com.jd.blockchain.capability.settings.CapabilitySettings; import com.jd.blockchain.capability.settings.CapabilitySettings;
import com.jd.blockchain.consensus.mq.factory.MsgQueueFactory; import com.jd.blockchain.consensus.mq.factory.MsgQueueFactory;
import com.jd.blockchain.consensus.mq.producer.MsgQueueProducer; 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.crypto.HashDigest;
import com.jd.blockchain.ledger.BlockchainIdentity; import com.jd.blockchain.ledger.BlockchainIdentity;
import com.jd.blockchain.ledger.BlockchainKeyGenerator; import com.jd.blockchain.ledger.BlockchainKeyGenerator;
@@ -317,7 +317,7 @@ public class RemoteTransactionService {
return txSerializeBytes; return txSerializeBytes;
} }


private TransactionRequest userRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) {
private TransactionRequest userRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) {
TxBuilder txbuilder = new TxBuilder(ledgerHash); TxBuilder txbuilder = new TxBuilder(ledgerHash);
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate();
txbuilder.users().register(userKey.getIdentity()); txbuilder.users().register(userKey.getIdentity());
@@ -326,7 +326,7 @@ public class RemoteTransactionService {
return reqBuilder.buildRequest(); 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); TxBuilder txbuilder = new TxBuilder(ledgerHash);
BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate();
BlockchainIdentity identity = dataAccountKey.getIdentity(); BlockchainIdentity identity = dataAccountKey.getIdentity();
@@ -339,7 +339,7 @@ public class RemoteTransactionService {
return reqBuilder.buildRequest(); return reqBuilder.buildRequest();
} }


private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) {
private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) {
TxBuilder txbuilder = new TxBuilder(ledgerHash); TxBuilder txbuilder = new TxBuilder(ledgerHash);
BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate();
BlockchainIdentity identity = dataAccountKey.getIdentity(); BlockchainIdentity identity = dataAccountKey.getIdentity();
@@ -350,7 +350,7 @@ public class RemoteTransactionService {
return reqBuilder.buildRequest(); 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); TxBuilder txbuilder = new TxBuilder(ledgerHash);
long currValue = keyPrefix.getAndIncrement(); long currValue = keyPrefix.getAndIncrement();
txbuilder.dataAccount(address).set("key-" + currValue + "-" + System.currentTimeMillis(), txbuilder.dataAccount(address).set("key-" + currValue + "-" + System.currentTimeMillis(),


+ 2
- 2
source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/service/SettingsInit.java View File

@@ -13,7 +13,7 @@ import com.jd.blockchain.capability.settings.CapabilitySettings;
import com.jd.blockchain.consensus.action.ActionResponse; import com.jd.blockchain.consensus.action.ActionResponse;
import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings; import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings;
import com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings; 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.HashDigest;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -118,7 +118,7 @@ public class SettingsInit {
// 处理用户 // 处理用户
PrivKey privKey = KeyGenCommand.decodePrivKeyWithRawPassword(settings.getPrivKey(), settings.getPwd()); PrivKey privKey = KeyGenCommand.decodePrivKeyWithRawPassword(settings.getPrivKey(), settings.getPwd());
PubKey pubKey = KeyGenCommand.decodePubKey(settings.getPubKey()); PubKey pubKey = KeyGenCommand.decodePubKey(settings.getPubKey());
CapabilitySettings.adminKey = new CryptoKeyPair(pubKey, privKey);
CapabilitySettings.adminKey = new AsymmetricKeypair(pubKey, privKey);
} }


private static class Settings { private static class Settings {


+ 2
- 2
source/tools/tools-capability/src/main/java/com/jd/blockchain/capability/settings/CapabilitySettings.java View File

@@ -8,7 +8,7 @@
*/ */
package com.jd.blockchain.capability.settings; package com.jd.blockchain.capability.settings;


import com.jd.blockchain.crypto.CryptoKeyPair;
import com.jd.blockchain.crypto.AsymmetricKeypair;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;


/** /**
@@ -41,7 +41,7 @@ public class CapabilitySettings {


public static HashDigest ledgerHash; public static HashDigest ledgerHash;


public static CryptoKeyPair adminKey;
public static AsymmetricKeypair adminKey;


public static final String settingsConf = "settings.conf"; public static final String settingsConf = "settings.conf";
} }

+ 2
- 2
source/tools/tools-keygen/src/main/java/com/jd/blockchain/tools/keygen/KeyGenCommand.java View File

@@ -8,7 +8,7 @@ import java.util.List;


import javax.crypto.SecretKey; 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.CryptoServiceProviders;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
@@ -104,7 +104,7 @@ public class KeyGenCommand {
* @param outputDir * @param outputDir
*/ */
private static void generateKeyPair(String name, String outputDir, String localConfPath) { 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()); String base58PubKey = encodePubKey(kp.getPubKey());




Loading…
Cancel
Save