@@ -10,7 +10,7 @@ import com.jd.blockchain.consensus.bftsmart.BftsmartClientIncomingSettings; | |||
import com.jd.blockchain.consensus.client.ClientFactory; | |||
import com.jd.blockchain.consensus.client.ClientSettings; | |||
import com.jd.blockchain.consensus.client.ConsensusClient; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -32,7 +32,7 @@ public class BftsmartConsensusClientFactory implements ClientFactory { | |||
@Override | |||
public BftsmartClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) { | |||
public BftsmartClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) { | |||
PubKey pubKey = clientKeyPair.getPubKey(); | |||
PrivKey privKey = clientKeyPair.getPrivKey(); | |||
@@ -3,7 +3,7 @@ package com.jd.blockchain.consensus.client; | |||
import com.jd.blockchain.consensus.ClientIdentification; | |||
import com.jd.blockchain.consensus.ClientIncomingSettings; | |||
import com.jd.blockchain.consensus.ConsensusManageService; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
public interface ClientFactory { | |||
@@ -13,7 +13,7 @@ public interface ClientFactory { | |||
* @param clientKeyPair | |||
* @return | |||
*/ | |||
ClientIdentification buildAuthId(CryptoKeyPair clientKeyPair); | |||
ClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair); | |||
/** | |||
* 根据接入配置信息创建客户端的本地连接配置; | |||
@@ -16,7 +16,7 @@ import com.jd.blockchain.consensus.mq.config.MsgQueueClientConfig; | |||
import com.jd.blockchain.consensus.mq.settings.MsgQueueClientIncomingSettings; | |||
import com.jd.blockchain.consensus.mq.settings.MsgQueueClientSettings; | |||
import com.jd.blockchain.consensus.mq.settings.MsgQueueConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -32,7 +32,7 @@ import com.jd.blockchain.crypto.SignatureFunction; | |||
public class MsgQueueClientFactory implements ClientFactory { | |||
@Override | |||
public MsgQueueClientIdentification buildAuthId(CryptoKeyPair clientKeyPair) { | |||
public MsgQueueClientIdentification buildAuthId(AsymmetricKeypair clientKeyPair) { | |||
PubKey pubKey = clientKeyPair.getPubKey(); | |||
byte[] address = pubKey.toBytes(); // 使用公钥地址作为认证信息 | |||
@@ -221,7 +221,7 @@ public class AESEncryptionFunction implements SymmetricEncryptionFunction { | |||
} | |||
@Override | |||
public CryptoKey generateSymmetricKey() { | |||
public SymmetricKey generateSymmetricKey() { | |||
// 根据对应的标识和原始密钥生成相应的密钥数据 | |||
return new SymmetricKey(AES, AESUtils.generateKey128_Bytes()); | |||
} | |||
@@ -1,7 +1,7 @@ | |||
package com.jd.blockchain.crypto.service.classic; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -63,7 +63,7 @@ public class ECDSASignatureFunction implements SignatureFunction { | |||
} | |||
@Override | |||
public CryptoKeyPair generateKeyPair() { | |||
public AsymmetricKeypair generateKeypair() { | |||
return null; | |||
} | |||
} |
@@ -7,7 +7,7 @@ import static com.jd.blockchain.crypto.CryptoKeyType.PUBLIC; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoException; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -154,7 +154,7 @@ public class ED25519SignatureFunction implements SignatureFunction { | |||
} | |||
@Override | |||
public CryptoKeyPair generateKeyPair() { | |||
public AsymmetricKeypair generateKeypair() { | |||
// 调用ED25519算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 | |||
AsymmetricCipherKeyPair keyPair = ED25519Utils.generateKeyPair(); | |||
Ed25519PrivateKeyParameters privKeyParams = (Ed25519PrivateKeyParameters) keyPair.getPrivate(); | |||
@@ -167,7 +167,7 @@ public class ED25519SignatureFunction implements SignatureFunction { | |||
// EdDSAPrivateKey privKey = (EdDSAPrivateKey) keyPair.getPrivate(); | |||
// EdDSAPublicKey pubKey = (EdDSAPublicKey) keyPair.getPublic(); | |||
// return new CryptoKeyPair(new PubKey(ED25519, pubKey.getAbyte()), new PrivKey(ED25519, privKey.getSeed())); | |||
return new CryptoKeyPair(new PubKey(ED25519, pubKeyBytes), new PrivKey(ED25519, privKeyBytes)); | |||
return new AsymmetricKeypair(new PubKey(ED25519, pubKeyBytes), new PrivKey(ED25519, privKeyBytes)); | |||
} | |||
} |
@@ -4,7 +4,7 @@ import com.jd.blockchain.crypto.AsymmetricCiphertext; | |||
import com.jd.blockchain.crypto.AsymmetricEncryptionFunction; | |||
import com.jd.blockchain.crypto.Ciphertext; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -88,7 +88,7 @@ public class RSACryptoFunction implements AsymmetricEncryptionFunction, Signatur | |||
} | |||
@Override | |||
public CryptoKeyPair generateKeyPair() { | |||
public AsymmetricKeypair generateKeypair() { | |||
return null; | |||
} | |||
} |
@@ -17,7 +17,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoException; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -64,7 +64,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -97,7 +97,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -122,7 +122,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
SignatureDigest signatureDigest = signatureFunction.sign(privKey,data); | |||
@@ -150,7 +150,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -168,7 +168,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
byte[] privKeyBytes = privKey.toBytes(); | |||
@@ -193,7 +193,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
byte[] privKeyBytes = privKey.toBytes(); | |||
@@ -233,7 +233,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
byte[] pubKeyBytes = pubKey.toBytes(); | |||
@@ -258,7 +258,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
byte[] pubKeyBytes = pubKey.toBytes(); | |||
@@ -304,7 +304,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = | |||
CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -335,7 +335,7 @@ public class ED25519SignatureFunctionTest { | |||
SignatureFunction signatureFunction = | |||
CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface AsymmetricEncryptionFunction extends CryptoKeyPairGenerator, CryptoFunction { | |||
public interface AsymmetricEncryptionFunction extends AsymmetricKeypairGenerator, CryptoFunction { | |||
/** | |||
* 加密; | |||
@@ -1,6 +1,12 @@ | |||
package com.jd.blockchain.crypto; | |||
public class CryptoKeyPair { | |||
/** | |||
* 非对称密钥对; | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
public class AsymmetricKeypair { | |||
private PubKey pubKey; | |||
@@ -18,7 +24,7 @@ public class CryptoKeyPair { | |||
return privKey; | |||
} | |||
public CryptoKeyPair(PubKey pubKey, PrivKey privKey) { | |||
public AsymmetricKeypair(PubKey pubKey, PrivKey privKey) { | |||
if (pubKey.getAlgorithm() != privKey.getAlgorithm()) { | |||
throw new IllegalArgumentException("The algorithms of PubKey and PrivKey don't match!"); | |||
} |
@@ -0,0 +1,10 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface AsymmetricKeypairGenerator { | |||
/** | |||
* 返回密钥对; | |||
*/ | |||
AsymmetricKeypair generateKeypair(); | |||
} |
@@ -1,10 +0,0 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface CryptoKeyPairGenerator { | |||
/** | |||
* 返回密钥对; | |||
*/ | |||
CryptoKeyPair generateKeyPair(); | |||
} |
@@ -1,9 +0,0 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface CryptoSymmetricKeyGenerator { | |||
/** | |||
* 返回对称密钥; | |||
*/ | |||
CryptoKey generateSymmetricKey(); | |||
} |
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface SignatureFunction extends CryptoKeyPairGenerator, CryptoFunction { | |||
public interface SignatureFunction extends AsymmetricKeypairGenerator, CryptoFunction { | |||
/** | |||
* 计算指定数据的 hash; | |||
@@ -3,7 +3,7 @@ package com.jd.blockchain.crypto; | |||
import java.io.InputStream; | |||
import java.io.OutputStream; | |||
public interface SymmetricEncryptionFunction extends CryptoSymmetricKeyGenerator, CryptoFunction { | |||
public interface SymmetricEncryptionFunction extends SymmetricKeyGenerator, CryptoFunction { | |||
/** | |||
* 加密; | |||
@@ -3,7 +3,7 @@ package com.jd.blockchain.crypto; | |||
import static com.jd.blockchain.crypto.CryptoKeyType.SYMMETRIC; | |||
/** | |||
* 单密钥; | |||
* 对称密钥; | |||
* | |||
* @author huanghaiquan | |||
* | |||
@@ -0,0 +1,9 @@ | |||
package com.jd.blockchain.crypto; | |||
public interface SymmetricKeyGenerator { | |||
/** | |||
* 返回对称密钥; | |||
*/ | |||
SymmetricKey generateSymmetricKey(); | |||
} |
@@ -14,7 +14,7 @@ import com.jd.blockchain.crypto.AsymmetricEncryptionFunction; | |||
import com.jd.blockchain.crypto.Ciphertext; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoException; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -210,7 +210,7 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur | |||
} | |||
@Override | |||
public CryptoKeyPair generateKeyPair() { | |||
public AsymmetricKeypair generateKeypair() { | |||
// 调用SM2算法的密钥生成算法生成公私钥对priKey和pubKey,返回密钥对 | |||
AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair(); | |||
@@ -230,6 +230,6 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur | |||
byte[] pubKeyBytes = ecPub.getQ().getEncoded(false); | |||
return new CryptoKeyPair(new PubKey(SM2, pubKeyBytes), new PrivKey(SM2, privKeyBytes)); | |||
return new AsymmetricKeypair(new PubKey(SM2, pubKeyBytes), new PrivKey(SM2, privKeyBytes)); | |||
} | |||
} |
@@ -205,7 +205,7 @@ public class SM4EncryptionFunction implements SymmetricEncryptionFunction { | |||
} | |||
@Override | |||
public CryptoKey generateSymmetricKey() { | |||
public SymmetricKey generateSymmetricKey() { | |||
// 根据对应的标识和原始密钥生成相应的密钥数据 | |||
return new SymmetricKey(SM4, SM4Utils.generateKey()); | |||
} | |||
@@ -49,7 +49,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -82,7 +82,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -107,7 +107,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
SignatureDigest signatureDigest = signatureFunction.sign(privKey, data); | |||
@@ -137,7 +137,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -159,7 +159,7 @@ public class SM2CyptoFunctionTest { | |||
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders | |||
.getAsymmetricEncryptionFunction(algorithm); | |||
CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
@@ -190,7 +190,7 @@ public class SM2CyptoFunctionTest { | |||
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders | |||
.getAsymmetricEncryptionFunction(algorithm); | |||
CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -210,7 +210,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
byte[] privKeyBytes = privKey.toBytes(); | |||
@@ -235,7 +235,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
byte[] privKeyBytes = privKey.toBytes(); | |||
@@ -275,7 +275,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
byte[] pubKeyBytes = pubKey.toBytes(); | |||
@@ -300,7 +300,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
byte[] pubKeyBytes = pubKey.toBytes(); | |||
@@ -344,7 +344,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -374,7 +374,7 @@ public class SM2CyptoFunctionTest { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(algorithm); | |||
CryptoKeyPair keyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = signatureFunction.generateKeypair(); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
@@ -420,7 +420,7 @@ public class SM2CyptoFunctionTest { | |||
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders | |||
.getAsymmetricEncryptionFunction(algorithm); | |||
CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
@@ -452,7 +452,7 @@ public class SM2CyptoFunctionTest { | |||
AsymmetricEncryptionFunction asymmetricEncryptionFunction = CryptoServiceProviders | |||
.getAsymmetricEncryptionFunction(algorithm); | |||
CryptoKeyPair keyPair = asymmetricEncryptionFunction.generateKeyPair(); | |||
AsymmetricKeypair keyPair = asymmetricEncryptionFunction.generateKeypair(); | |||
PubKey pubKey = keyPair.getPubKey(); | |||
@@ -11,7 +11,7 @@ import org.springframework.boot.SpringApplication; | |||
import org.springframework.context.ConfigurableApplicationContext; | |||
import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.tools.keygen.KeyGenCommand; | |||
@@ -80,7 +80,7 @@ public class GatewayServerBooter { | |||
private volatile ConfigurableApplicationContext appCtx; | |||
private GatewayConfigProperties config; | |||
private CryptoKeyPair defaultKeyPair; | |||
private AsymmetricKeypair defaultKeyPair; | |||
private String springConfigLocation; | |||
public GatewayServerBooter(GatewayConfigProperties config, String springConfigLocation) { | |||
this.config = config; | |||
@@ -102,7 +102,7 @@ public class GatewayServerBooter { | |||
} else { | |||
privKey = KeyGenCommand.decodePrivKey(base58PrivKey, base58Pwd); | |||
} | |||
defaultKeyPair = new CryptoKeyPair(pubKey, privKey); | |||
defaultKeyPair = new AsymmetricKeypair(pubKey, privKey); | |||
} | |||
public synchronized void start() { | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.gateway; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.utils.net.NetworkAddress; | |||
import java.util.List; | |||
@@ -11,7 +11,7 @@ public interface PeerConnector { | |||
boolean isConnected(); | |||
void connect(NetworkAddress peerAddress, CryptoKeyPair defaultKeyPair, List<String> peerProviders); | |||
void connect(NetworkAddress peerAddress, AsymmetricKeypair defaultKeyPair, List<String> peerProviders); | |||
void reconnect(); | |||
@@ -4,7 +4,7 @@ import javax.annotation.PreDestroy; | |||
import org.springframework.stereotype.Component; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.gateway.PeerConnector; | |||
import com.jd.blockchain.gateway.PeerService; | |||
import com.jd.blockchain.ledger.data.TransactionService; | |||
@@ -21,7 +21,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { | |||
private volatile NetworkAddress peerAddress; | |||
private volatile CryptoKeyPair gateWayKeyPair; | |||
private volatile AsymmetricKeypair gateWayKeyPair; | |||
private volatile List<String> peerProviders; | |||
@@ -36,7 +36,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { | |||
} | |||
@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 (this.peerAddress.equals(peerAddress)) { | |||
return; | |||
@@ -98,7 +98,7 @@ public class PeerConnectionManager implements PeerService, PeerConnector { | |||
this.peerAddress = peerAddress; | |||
} | |||
public void setGateWayKeyPair(CryptoKeyPair gateWayKeyPair) { | |||
public void setGateWayKeyPair(AsymmetricKeypair gateWayKeyPair) { | |||
this.gateWayKeyPair = gateWayKeyPair; | |||
} | |||
@@ -9,7 +9,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
import com.jd.blockchain.crypto.service.classic.ClassicCryptoService; | |||
@@ -57,7 +57,7 @@ public class LedgerEditerTest { | |||
LedgerTransactionContext txCtx = ldgEdt.newTransaction(genesisTxReq); | |||
LedgerDataSet ldgDS = txCtx.getDataSet(); | |||
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); | |||
@Test | |||
public void testWriteDataAccoutKvOp() { | |||
@@ -121,7 +121,7 @@ public class LedgerEditerTest { | |||
parties[0] = new ConsensusParticipantData(); | |||
parties[0].setId(0); | |||
parties[0].setName("John"); | |||
CryptoKeyPair kp0 = signFunc.generateKeyPair(); | |||
AsymmetricKeypair kp0 = signFunc.generateKeypair(); | |||
parties[0].setPubKey(kp0.getPubKey()); | |||
parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); | |||
parties[0].setHostAddress(new NetworkAddress("192.168.1.6", 9000)); | |||
@@ -129,7 +129,7 @@ public class LedgerEditerTest { | |||
parties[1] = new ConsensusParticipantData(); | |||
parties[1].setId(1); | |||
parties[1].setName("John"); | |||
CryptoKeyPair kp1 = signFunc.generateKeyPair(); | |||
AsymmetricKeypair kp1 = signFunc.generateKeypair(); | |||
parties[1].setPubKey(kp1.getPubKey()); | |||
parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); | |||
parties[1].setHostAddress(new NetworkAddress("192.168.1.7", 9000)); | |||
@@ -11,7 +11,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -182,7 +182,7 @@ public class LedgerManagerTest { | |||
parties[0] = new ConsensusParticipantData(); | |||
parties[0].setId(0); | |||
parties[0].setName("John"); | |||
CryptoKeyPair kp0 = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair kp0 = signatureFunction.generateKeypair(); | |||
parties[0].setPubKey(kp0.getPubKey()); | |||
parties[0].setAddress(AddressEncoding.generateAddress(kp0.getPubKey()).toBase58()); | |||
parties[0].setHostAddress(new NetworkAddress("127.0.0.1", 9000)); | |||
@@ -190,7 +190,7 @@ public class LedgerManagerTest { | |||
parties[1] = new ConsensusParticipantData(); | |||
parties[1].setId(1); | |||
parties[1].setName("Mary"); | |||
CryptoKeyPair kp1 = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair kp1 = signatureFunction.generateKeypair(); | |||
parties[1].setPubKey(kp1.getPubKey()); | |||
parties[1].setAddress(AddressEncoding.generateAddress(kp1.getPubKey()).toBase58()); | |||
parties[1].setHostAddress(new NetworkAddress("127.0.0.1", 9010)); | |||
@@ -198,7 +198,7 @@ public class LedgerManagerTest { | |||
parties[2] = new ConsensusParticipantData(); | |||
parties[2].setId(2); | |||
parties[2].setName("Jerry"); | |||
CryptoKeyPair kp2 = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair kp2 = signatureFunction.generateKeypair(); | |||
parties[2].setPubKey(kp2.getPubKey()); | |||
parties[2].setAddress(AddressEncoding.generateAddress(kp2.getPubKey()).toBase58()); | |||
parties[2].setHostAddress(new NetworkAddress("127.0.0.1", 9020)); | |||
@@ -206,7 +206,7 @@ public class LedgerManagerTest { | |||
parties[3] = new ConsensusParticipantData(); | |||
parties[3].setId(3); | |||
parties[3].setName("Tom"); | |||
CryptoKeyPair kp3 = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair kp3 = signatureFunction.generateKeypair(); | |||
parties[3].setPubKey(kp3.getPubKey()); | |||
parties[3].setAddress(AddressEncoding.generateAddress(kp3.getPubKey()).toBase58()); | |||
parties[3].setHostAddress(new NetworkAddress("127.0.0.1", 9030)); | |||
@@ -2,7 +2,7 @@ package test.com.jd.blockchain.ledger; | |||
import java.util.Random; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -34,7 +34,7 @@ public class LedgerTestUtils { | |||
TxTemplate txTemp = new TxTemplate(ledgerHash, txHandle); | |||
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = cryptoKeyPair.getPubKey(); | |||
txTemp.users().register(new BlockchainIdentityData(pubKey)); | |||
PreparedTransaction ptx = txTemp.prepare(); | |||
@@ -51,7 +51,7 @@ public class LedgerTestUtils { | |||
txTemp.contractEvents().send(contractAddress, event, args); | |||
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); | |||
PubKey pubKey = cryptoKeyPair.getPubKey(); | |||
txTemp.users().register(new BlockchainIdentityData(pubKey)); | |||
PreparedTransaction ptx = txTemp.prepare(); | |||
@@ -1,7 +1,7 @@ | |||
package com.jd.blockchain.ledger; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -33,7 +33,7 @@ public class BlockchainKeyGenerator { | |||
public BlockchainKeyPair generate(CryptoAlgorithm signatureAlgorithm) { | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction(signatureAlgorithm); | |||
CryptoKeyPair cryptoKeyPair = signFunc.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair(); | |||
return new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.ledger; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.utils.Bytes; | |||
@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.Bytes; | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
public class BlockchainKeyPair extends CryptoKeyPair { | |||
public class BlockchainKeyPair extends AsymmetricKeypair { | |||
private BlockchainIdentity id; | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.ledger; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -39,7 +39,7 @@ public interface PreparedTransaction extends HashObject { | |||
* 签名账户的私钥; | |||
* @return | |||
*/ | |||
DigitalSignature sign(CryptoKeyPair keyPair); | |||
DigitalSignature sign(AsymmetricKeypair keyPair); | |||
/** | |||
* 加入签名; | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.ledger; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
/** | |||
@@ -38,7 +38,7 @@ public interface TransactionRequestBuilder extends HashObject { | |||
* 签名账户的私钥; | |||
* @return | |||
*/ | |||
DigitalSignature signAsEndpoint(CryptoKeyPair keyPair); | |||
DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair); | |||
/** | |||
* 对交易进行签名; | |||
@@ -49,7 +49,7 @@ public interface TransactionRequestBuilder extends HashObject { | |||
* 签名账户的私钥; | |||
* @return | |||
*/ | |||
DigitalSignature signAsNode(CryptoKeyPair keyPair); | |||
DigitalSignature signAsNode(AsymmetricKeypair keyPair); | |||
/** | |||
* 加入签名; | |||
@@ -1,7 +1,7 @@ | |||
package com.jd.blockchain.ledger.data; | |||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -36,7 +36,7 @@ public class PreparedTx implements PreparedTransaction { | |||
} | |||
@Override | |||
public DigitalSignature sign(CryptoKeyPair keyPair) { | |||
public DigitalSignature sign(AsymmetricKeypair keyPair) { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction(keyPair.getAlgorithm()); | |||
PrivKey privKey = keyPair.getPrivKey(); | |||
byte[] content = BinaryEncodingUtils.encode(getTransactionContent(), TransactionContent.class); | |||
@@ -4,7 +4,7 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -41,14 +41,14 @@ public class TxRequestBuilder implements TransactionRequestBuilder { | |||
} | |||
@Override | |||
public DigitalSignature signAsEndpoint(CryptoKeyPair keyPair) { | |||
public DigitalSignature signAsEndpoint(AsymmetricKeypair keyPair) { | |||
DigitalSignature signature = sign(txContent, keyPair); | |||
addEndpointSignature(signature); | |||
return signature; | |||
} | |||
@Override | |||
public DigitalSignature signAsNode(CryptoKeyPair keyPair) { | |||
public DigitalSignature signAsNode(AsymmetricKeypair keyPair) { | |||
DigitalSignature signature = sign(txContent, keyPair); | |||
addNodeSignature(signature); | |||
return signature; | |||
@@ -64,7 +64,7 @@ public class TxRequestBuilder implements TransactionRequestBuilder { | |||
endpointSignatures.add(signature); | |||
} | |||
public static DigitalSignature sign(TransactionContent txContent, CryptoKeyPair keyPair) { | |||
public static DigitalSignature sign(TransactionContent txContent, AsymmetricKeypair keyPair) { | |||
SignatureDigest signatureDigest = sign(txContent, keyPair.getPrivKey()); | |||
DigitalSignature signature = new DigitalSignatureBlob(keyPair.getPubKey(), signatureDigest); | |||
return signature; | |||
@@ -43,7 +43,7 @@ public class ContractCodeDeployOpTemplateTest { | |||
DataContractRegistry.register(ContractCodeDeployOperation.class); | |||
DataContractRegistry.register(Operation.class); | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
PubKey pubKey = signFunc.generateKeyPair().getPubKey(); | |||
PubKey pubKey = signFunc.generateKeypair().getPubKey(); | |||
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); | |||
byte[] chainCode = "jd-test".getBytes(); | |||
data = new ContractCodeDeployOpTemplate(contractID, chainCode); | |||
@@ -40,7 +40,7 @@ public class DataAccountRegisterOpTemplateTest { | |||
DataContractRegistry.register(DataAccountRegisterOperation.class); | |||
DataContractRegistry.register(Operation.class); | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
PubKey pubKey = signFunc.generateKeyPair().getPubKey(); | |||
PubKey pubKey = signFunc.generateKeypair().getPubKey(); | |||
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); | |||
data = new DataAccountRegisterOpTemplate(contractID); | |||
@@ -16,7 +16,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -41,7 +41,7 @@ public class DigitalSignatureBlobTest { | |||
DataContractRegistry.register(DigitalSignature.class); | |||
DataContractRegistry.register(DigitalSignatureBody.class); | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
CryptoKeyPair kp = signFunc.generateKeyPair(); | |||
AsymmetricKeypair kp = signFunc.generateKeypair(); | |||
PubKey pubKey = kp.getPubKey(); | |||
SignatureDigest digest = signFunc.sign(kp.getPrivKey(), "zhangsan".getBytes()); | |||
@@ -4,7 +4,7 @@ import java.util.Random; | |||
import org.junit.Test; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
import com.jd.blockchain.utils.security.Ed25519Utils; | |||
@@ -18,7 +18,7 @@ public class ED25519SignatureTest { | |||
rand.nextBytes(data); | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
CryptoKeyPair key = signFunc.generateKeyPair(); | |||
AsymmetricKeypair key = signFunc.generateKeypair(); | |||
byte[] pubKey = key.getPubKey().getRawKeyBytes(); | |||
byte[] privKey = key.getPrivKey().getRawKeyBytes(); | |||
@@ -17,7 +17,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -60,10 +60,10 @@ public class TxRequestMessageTest { | |||
data = new TxRequestMessage(initTransactionContent()); | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
CryptoKeyPair key1 = signFunc.generateKeyPair(); | |||
CryptoKeyPair key2 = signFunc.generateKeyPair(); | |||
CryptoKeyPair key3 = signFunc.generateKeyPair(); | |||
CryptoKeyPair key4 = signFunc.generateKeyPair(); | |||
AsymmetricKeypair key1 = signFunc.generateKeypair(); | |||
AsymmetricKeypair key2 = signFunc.generateKeypair(); | |||
AsymmetricKeypair key3 = signFunc.generateKeypair(); | |||
AsymmetricKeypair key4 = signFunc.generateKeypair(); | |||
SignatureDigest digest1 = signFunc.sign(key1.getPrivKey(), "zhangsan".getBytes()); | |||
SignatureDigest digest2 = signFunc.sign(key2.getPrivKey(), "lisi".getBytes()); | |||
@@ -15,7 +15,7 @@ import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PubKey; | |||
import com.jd.blockchain.ledger.BlockchainIdentity; | |||
@@ -39,7 +39,7 @@ public class UserRegisterOpTemplateTest { | |||
public void initUserRegisterOpTemplate() { | |||
DataContractRegistry.register(UserRegisterOperation.class); | |||
DataContractRegistry.register(Operation.class); | |||
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); | |||
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); | |||
PubKey pubKey = key.getPubKey(); | |||
BlockchainIdentity contractID = new BlockchainIdentityData(pubKey); | |||
data = new UserRegisterOpTemplate(contractID); | |||
@@ -5,7 +5,7 @@ import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.consensus.MessageService; | |||
import com.jd.blockchain.consensus.client.ConsensusClient; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -37,11 +37,11 @@ public class NodeSigningAppender implements TransactionService { | |||
private ConsensusClient consensusClient; | |||
private CryptoKeyPair nodeKeyPair; | |||
private AsymmetricKeypair nodeKeyPair; | |||
private CryptoAlgorithm hashAlgorithm; | |||
public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, CryptoKeyPair nodeKeyPair, ConsensusClient consensusClient) { | |||
public NodeSigningAppender(CryptoAlgorithm hashAlgorithm, AsymmetricKeypair nodeKeyPair, ConsensusClient consensusClient) { | |||
this.hashAlgorithm = hashAlgorithm; | |||
this.nodeKeyPair = nodeKeyPair; | |||
this.consensusClient = consensusClient; | |||
@@ -4,7 +4,7 @@ import com.jd.blockchain.consensus.*; | |||
import com.jd.blockchain.consensus.client.ClientFactory; | |||
import com.jd.blockchain.consensus.client.ClientSettings; | |||
import com.jd.blockchain.consensus.client.ConsensusClient; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.ledger.CryptoSetting; | |||
import com.jd.blockchain.ledger.data.TransactionService; | |||
@@ -88,7 +88,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C | |||
* | |||
* @return 区块链服务工厂实例; | |||
*/ | |||
public static PeerBlockchainServiceFactory connect(CryptoKeyPair gatewayKey, NetworkAddress peerAddr, List<String> peerProviders) { | |||
public static PeerBlockchainServiceFactory connect(AsymmetricKeypair gatewayKey, NetworkAddress peerAddr, List<String> peerProviders) { | |||
if (peerProviders == null || peerProviders.isEmpty()) { | |||
throw new AuthenticationException("No peer Provider was set!"); | |||
@@ -245,7 +245,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C | |||
* @param cryptoSetting | |||
* @return | |||
*/ | |||
private static TransactionService enableGatewayAutoSigning(CryptoKeyPair nodeKeyPair, CryptoSetting cryptoSetting, | |||
private static TransactionService enableGatewayAutoSigning(AsymmetricKeypair nodeKeyPair, CryptoSetting cryptoSetting, | |||
ConsensusClient consensusClient) { | |||
NodeSigningAppender signingAppender = new NodeSigningAppender(cryptoSetting.getHashAlgorithm(), | |||
nodeKeyPair, consensusClient); | |||
@@ -265,7 +265,7 @@ public class PeerBlockchainServiceFactory implements BlockchainServiceFactory, C | |||
} | |||
} | |||
private static ClientIdentificationsProvider authIdProvider(CryptoKeyPair gatewayKey, List<String> peerProviders) { | |||
private static ClientIdentificationsProvider authIdProvider(AsymmetricKeypair gatewayKey, List<String> peerProviders) { | |||
ClientIdentificationsProvider authIdProvider = new ClientIdentificationsProvider(); | |||
for (String peerProvider : peerProviders) { | |||
ConsensusProvider provider = ConsensusProviders.getProvider(peerProvider); | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -88,7 +88,7 @@ public class SDKDemo_Contract { | |||
String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -107,9 +107,9 @@ public class SDKDemo_Contract { | |||
* | |||
* @return | |||
*/ | |||
private static CryptoKeyPair getSponsorKey() { | |||
private static AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
/** | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -61,7 +61,7 @@ public class SDKDemo_DataAccount { | |||
PreparedTransaction prepTx = txTemp.prepare(); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -73,9 +73,9 @@ public class SDKDemo_DataAccount { | |||
return null; | |||
} | |||
private static CryptoKeyPair getSponsorKey() { | |||
private static AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -67,7 +67,7 @@ public class SDKDemo_InsertData { | |||
String txHash = ByteArray.toBase64(prepTx.getHash().toBytes()); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -79,9 +79,9 @@ public class SDKDemo_InsertData { | |||
return null; | |||
} | |||
private static CryptoKeyPair getSponsorKey() { | |||
private static AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
/** | |||
@@ -1,7 +1,7 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.ledger.*; | |||
import com.jd.blockchain.sdk.BlockchainService; | |||
@@ -37,7 +37,7 @@ public class SDKDemo_RegisterAccount { | |||
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); | |||
//existed signer | |||
CryptoKeyPair keyPair = new BlockchainKeyPair(SDKDemo_Params.pubKey1, SDKDemo_Params.privkey1); | |||
AsymmetricKeypair keyPair = new BlockchainKeyPair(SDKDemo_Params.pubKey1, SDKDemo_Params.privkey1); | |||
BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -9,7 +9,7 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -9,7 +9,7 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -58,7 +58,7 @@ public class SDKDemo_RegisterUser { | |||
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); | |||
//existed signer | |||
CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey); | |||
AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey); | |||
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -1,6 +1,6 @@ | |||
package com.jd.blockchain.sdk.samples; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
@@ -64,7 +64,7 @@ public class SDKDemo_User { | |||
//BlockchainKeyPair user = generator.generate(CryptoKeyType.PUBLIC); | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); | |||
BlockchainKeyPair user = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey()); | |||
txTemp.users().register(user.getIdentity()); | |||
@@ -75,7 +75,7 @@ public class SDKDemo_User { | |||
PreparedTransaction prepTx = txTemp.prepare(); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -87,9 +87,9 @@ public class SDKDemo_User { | |||
return null; | |||
} | |||
private static CryptoKeyPair getSponsorKey() { | |||
private static AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
} |
@@ -14,7 +14,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -99,7 +99,7 @@ public class SDK_GateWay_BatchInsertData_Test_ { | |||
PreparedTransaction prepTx = txTemp.prepare(); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -123,9 +123,9 @@ public class SDK_GateWay_BatchInsertData_Test_ { | |||
} | |||
private CryptoKeyPair getSponsorKey() { | |||
private AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
private TransactionResponse initResponse() { | |||
@@ -12,7 +12,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -81,7 +81,7 @@ public class SDK_GateWay_DataAccount_Test_ { | |||
// CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
//existed signer | |||
CryptoKeyPair keyPair = new BlockchainKeyPair(SDK_GateWay_KeyPair_Para.pubKey1, SDK_GateWay_KeyPair_Para.privkey1); | |||
AsymmetricKeypair keyPair = new BlockchainKeyPair(SDK_GateWay_KeyPair_Para.pubKey1, SDK_GateWay_KeyPair_Para.privkey1); | |||
BlockchainKeyPair dataAcount = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -118,8 +118,8 @@ public class SDK_GateWay_DataAccount_Test_ { | |||
return CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
} | |||
private CryptoKeyPair getSponsorKey() { | |||
return getSignatureFunction().generateKeyPair(); | |||
private AsymmetricKeypair getSponsorKey() { | |||
return getSignatureFunction().generateKeypair(); | |||
} | |||
private TransactionResponse initResponse() { | |||
@@ -14,7 +14,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -92,7 +92,7 @@ public class SDK_GateWay_InsertData_Test_ { | |||
PreparedTransaction prepTx = txTemp.prepare(); | |||
// 使用私钥进行签名; | |||
CryptoKeyPair keyPair = getSponsorKey(); | |||
AsymmetricKeypair keyPair = getSponsorKey(); | |||
prepTx.sign(keyPair); | |||
// 提交交易; | |||
@@ -117,9 +117,9 @@ public class SDK_GateWay_InsertData_Test_ { | |||
} | |||
private CryptoKeyPair getSponsorKey() { | |||
private AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
private TransactionResponse initResponse() { | |||
@@ -12,7 +12,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -186,7 +186,7 @@ public class SDK_GateWay_Query_Test_ { | |||
private BlockchainKeyPair getSponsorKey() { | |||
SignatureFunction signatureFunction = getSignatureFunction(); | |||
CryptoKeyPair cryptoKeyPair = signatureFunction.generateKeyPair(); | |||
AsymmetricKeypair cryptoKeyPair = signatureFunction.generateKeypair(); | |||
BlockchainKeyPair blockchainKeyPair = new BlockchainKeyPair(cryptoKeyPair.getPubKey(), | |||
cryptoKeyPair.getPrivKey()); | |||
return blockchainKeyPair; | |||
@@ -14,7 +14,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.HashFunction; | |||
@@ -103,7 +103,7 @@ public class SDK_GateWay_User_Test_ { | |||
TransactionTemplate txTemp = service.newTransaction(ledgerHashs[0]); | |||
//existed signer | |||
CryptoKeyPair keyPair = new BlockchainKeyPair(pubKey, privKey); | |||
AsymmetricKeypair keyPair = new BlockchainKeyPair(pubKey, privKey); | |||
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -137,9 +137,9 @@ public class SDK_GateWay_User_Test_ { | |||
// return new HashDigest(hashBytes); | |||
// } | |||
private CryptoKeyPair getSponsorKey() { | |||
private AsymmetricKeypair getSponsorKey() { | |||
SignatureFunction signatureFunction = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
return signatureFunction.generateKeyPair(); | |||
return signatureFunction.generateKeypair(); | |||
} | |||
private TransactionResponse initResponse() { | |||
@@ -5,7 +5,7 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.ledger.core.impl.LedgerManager; | |||
import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory; | |||
import com.jd.blockchain.tools.initializer.LedgerBindingConfig; | |||
@@ -37,7 +37,7 @@ public class IntegratedContext { | |||
private int id; | |||
private CryptoKeyPair partiKeyPair; | |||
private AsymmetricKeypair partiKeyPair; | |||
// private NetworkAddress consensusAddress; | |||
private ConsensusSettings consensusSettings; | |||
@@ -64,11 +64,11 @@ public class IntegratedContext { | |||
return storageDB; | |||
} | |||
public CryptoKeyPair getPartiKeyPair() { | |||
public AsymmetricKeypair getPartiKeyPair() { | |||
return partiKeyPair; | |||
} | |||
public void setPartiKeyPair(CryptoKeyPair partiKeyPair) { | |||
public void setPartiKeyPair(AsymmetricKeypair partiKeyPair) { | |||
this.partiKeyPair = partiKeyPair; | |||
} | |||
@@ -14,7 +14,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -169,7 +169,7 @@ public class IntegrationTest { | |||
HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); | |||
CryptoKeyPair adminKey = context.getNode(0).getPartiKeyPair(); | |||
AsymmetricKeypair adminKey = context.getNode(0).getPartiKeyPair(); | |||
BlockchainKeyPair newUserAcount = testSDK_RegisterUser(adminKey, ledgerHashs[0], bcsrv, context); | |||
@@ -184,7 +184,7 @@ public class IntegrationTest { | |||
} | |||
private void testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
private void testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
String dataAccountAddress, IntegratedContext context) { | |||
// 在本地定义注册账号的 TX; | |||
@@ -223,7 +223,7 @@ public class IntegrationTest { | |||
} | |||
} | |||
private static BlockchainKeyPair testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private static BlockchainKeyPair testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
// 注册用户,并验证最终写入; | |||
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -253,7 +253,7 @@ public class IntegrationTest { | |||
return user; | |||
} | |||
private BlockchainKeyPair testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private BlockchainKeyPair testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
// 注册数据账户,并验证最终写入; | |||
BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -286,7 +286,7 @@ public class IntegrationTest { | |||
return dataAccount; | |||
} | |||
private void testSDK_Query(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
private void testSDK_Query(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
IntegratedContext context, BlockchainKeyPair newUserAcount, BlockchainKeyPair newDataAcount) { | |||
Bytes userAddress = newUserAcount.getAddress(); | |||
@@ -501,7 +501,7 @@ public class IntegrationTest { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -509,7 +509,7 @@ public class IntegrationTest { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -517,7 +517,7 @@ public class IntegrationTest { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -525,7 +525,7 @@ public class IntegrationTest { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -547,7 +547,7 @@ public class IntegrationTest { | |||
} | |||
} | |||
private LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
// valid the basic data in contract; | |||
prepareContractData(adminKey, ledgerHash, blockchainService, context); | |||
@@ -585,7 +585,7 @@ public class IntegrationTest { | |||
return block; | |||
} | |||
private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); | |||
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); | |||
@@ -616,7 +616,7 @@ public class IntegrationTest { | |||
// 验证合约中的赋值,外部可以获得; | |||
DataAccountSet dataAccountSet = ledgerOfNode0.getDataAccountSet(backgroundLedgerBlock); | |||
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); | |||
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); | |||
PubKey pubKey = key.getPubKey(); | |||
Bytes dataAddress = AddressEncoding.generateAddress(pubKey); | |||
@@ -629,7 +629,7 @@ public class IntegrationTest { | |||
// assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); | |||
} | |||
private void prepareContractData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
private void prepareContractData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
IntegratedContext context) { | |||
// 定义交易; | |||
@@ -14,7 +14,7 @@ import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -162,7 +162,7 @@ public class ConsensusTest { | |||
} | |||
private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, | |||
CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length]; | |||
for (int i = 0; i < ptxs.length; i++) { | |||
// 定义交易; | |||
@@ -252,7 +252,7 @@ public class ConsensusTest { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -260,7 +260,7 @@ public class ConsensusTest { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -268,7 +268,7 @@ public class ConsensusTest { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -276,7 +276,7 @@ public class ConsensusTest { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.SignatureDigest; | |||
@@ -160,7 +160,7 @@ public class GlobalPerformanceTest { | |||
} | |||
private static PreparedTransaction[] prepareTransactions_RegisterDataAcount(BlockchainKeyPair[] userKeys, | |||
CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
PreparedTransaction[] ptxs = new PreparedTransaction[userKeys.length]; | |||
for (int i = 0; i < ptxs.length; i++) { | |||
// 定义交易; | |||
@@ -250,7 +250,7 @@ public class GlobalPerformanceTest { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -258,7 +258,7 @@ public class GlobalPerformanceTest { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -266,7 +266,7 @@ public class GlobalPerformanceTest { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -274,7 +274,7 @@ public class GlobalPerformanceTest { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -12,7 +12,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -168,9 +168,9 @@ public class LedgerInitializeTest { | |||
private LedgerInitProcess initProcess; | |||
private CryptoKeyPair partiKey; | |||
private AsymmetricKeypair partiKey; | |||
public CryptoKeyPair getPartiKey() { | |||
public AsymmetricKeypair getPartiKey() { | |||
return partiKey; | |||
} | |||
@@ -198,7 +198,7 @@ public class LedgerInitializeTest { | |||
ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, | |||
Prompter prompter) { | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -219,7 +219,7 @@ public class LedgerInitializeTest { | |||
cryptoSetting.setAutoVerifyHash(autoVerifyHash); | |||
cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -17,7 +17,7 @@ import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -178,7 +178,7 @@ public class LedgerPerformanceTest { | |||
* @param batchCount | |||
* @param silent | |||
*/ | |||
private static void testUserRegistering(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, | |||
private static void testUserRegistering(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, | |||
DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { | |||
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); | |||
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [注册用户] ================="); | |||
@@ -219,7 +219,7 @@ public class LedgerPerformanceTest { | |||
* @param batchCount | |||
* @param silent | |||
*/ | |||
private static void testKVWrite(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, | |||
private static void testKVWrite(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, | |||
DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { | |||
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); | |||
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [写入数据] ================="); | |||
@@ -273,7 +273,7 @@ public class LedgerPerformanceTest { | |||
* @param batchCount | |||
* @param silent | |||
*/ | |||
private static void testContract(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, | |||
private static void testContract(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, | |||
DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount, boolean silent) { | |||
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); | |||
ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [执行合约] ================="); | |||
@@ -356,7 +356,7 @@ public class LedgerPerformanceTest { | |||
} | |||
public static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count, | |||
CryptoKeyPair adminKey) { | |||
AsymmetricKeypair adminKey) { | |||
long startTs = System.currentTimeMillis(); | |||
List<TransactionRequest> txList = new ArrayList<>(); | |||
for (int i = 0; i < count; i++) { | |||
@@ -376,7 +376,7 @@ public class LedgerPerformanceTest { | |||
} | |||
public static List<TransactionRequest> prepareDataAccountRegisterRequests(HashDigest ledgerHash, | |||
BlockchainIdentity[] dataAccounts, CryptoKeyPair adminKey, boolean statistic) { | |||
BlockchainIdentity[] dataAccounts, AsymmetricKeypair adminKey, boolean statistic) { | |||
int count = dataAccounts.length; | |||
long startTs = System.currentTimeMillis(); | |||
List<TransactionRequest> txList = new ArrayList<>(); | |||
@@ -400,7 +400,7 @@ public class LedgerPerformanceTest { | |||
} | |||
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(); | |||
List<TransactionRequest> txList = new ArrayList<>(); | |||
for (int i = 0; i < count; i++) { | |||
@@ -428,7 +428,7 @@ public class LedgerPerformanceTest { | |||
return ConsensusProviders.getProvider(provider); | |||
} | |||
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 | |||
byte[] chainCode; | |||
@@ -11,7 +11,7 @@ import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -81,9 +81,9 @@ public class Utils { | |||
private LedgerInitProcess initProcess; | |||
private CryptoKeyPair partiKey; | |||
private AsymmetricKeypair partiKey; | |||
public CryptoKeyPair getPartiKey() { | |||
public AsymmetricKeypair getPartiKey() { | |||
return partiKey; | |||
} | |||
@@ -109,7 +109,7 @@ public class Utils { | |||
ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, | |||
Prompter prompter) { | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -145,7 +145,7 @@ public class Utils { | |||
ConsensusSettings csProps, ConsensusProvider consensusProvider, DBConnectionConfig dbConnConfig, | |||
Prompter prompter, CryptoSetting cryptoSetting) { | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -10,7 +10,7 @@ package test.com.jd.blockchain.intgr; | |||
import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.ledger.*; | |||
import com.jd.blockchain.ledger.core.LedgerManage; | |||
@@ -73,7 +73,7 @@ public class IntegrationBase { | |||
public static final AtomicLong validLong = new AtomicLong(); | |||
public static KeyPairResponse testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
public static KeyPairResponse testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
// 注册用户,并验证最终写入; | |||
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -98,7 +98,7 @@ public class IntegrationBase { | |||
return keyPairResponse; | |||
} | |||
public static KeyPairResponse testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
public static KeyPairResponse testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService) { | |||
// 注册数据账户,并验证最终写入; | |||
BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -123,7 +123,7 @@ public class IntegrationBase { | |||
return keyPairResponse; | |||
} | |||
public static KvResponse testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
public static KvResponse testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
Bytes dataAccount) { | |||
// 在本地定义注册账号的 TX; | |||
@@ -440,7 +440,7 @@ public class IntegrationBase { | |||
HashDigest txContentHash; | |||
String pubKeyVal = "jd.com"+System.currentTimeMillis(); | |||
private String eventName = "issue-asset"; | |||
public LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
public LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService,LedgerRepository ledgerRepository) { | |||
System.out.println("adminKey="+ AddressEncoding.generateAddress(adminKey.getPubKey())); | |||
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -475,7 +475,7 @@ public class IntegrationBase { | |||
return block; | |||
} | |||
private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
BlockchainService blockchainService,LedgerRepository ledgerRepository) { | |||
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); | |||
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); | |||
@@ -3,7 +3,7 @@ package test.com.jd.blockchain.intgr; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; | |||
@@ -197,7 +197,7 @@ public class IntegrationBaseTest { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -205,7 +205,7 @@ public class IntegrationBaseTest { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -213,7 +213,7 @@ public class IntegrationBaseTest { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -221,7 +221,7 @@ public class IntegrationBaseTest { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -18,7 +18,7 @@ import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.gateway.GatewayConfigProperties.KeyPairConfig; | |||
@@ -150,7 +150,7 @@ public class IntegrationTest2 { | |||
HashDigest[] ledgerHashs = bcsrv.getLedgerHashs(); | |||
CryptoKeyPair adminKey = context.getNode(0).getPartiKeyPair(); | |||
AsymmetricKeypair adminKey = context.getNode(0).getPartiKeyPair(); | |||
testSDK_Contract(adminKey, ledgerHashs[0], bcsrv, context); | |||
@@ -239,7 +239,7 @@ public class IntegrationTest2 { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -247,7 +247,7 @@ public class IntegrationTest2 { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -255,7 +255,7 @@ public class IntegrationTest2 { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -263,7 +263,7 @@ public class IntegrationTest2 { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -285,7 +285,7 @@ public class IntegrationTest2 { | |||
} | |||
} | |||
private void testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private void testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -307,7 +307,7 @@ public class IntegrationTest2 { | |||
testContractExe(adminKey, ledgerHash, userKey, blockchainService, context); | |||
} | |||
private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
BlockchainService blockchainService, IntegratedContext context) { | |||
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); | |||
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight()-1); | |||
@@ -1,6 +1,6 @@ | |||
package test.com.jd.blockchain.intgr; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -101,7 +101,7 @@ public class IntegrationTest4Bftsmart { | |||
PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); | |||
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); | |||
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); | |||
BlockchainService blockchainService = gwsrvFact.getBlockchainService(); | |||
@@ -1,6 +1,6 @@ | |||
package test.com.jd.blockchain.intgr; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -111,7 +111,7 @@ public class IntegrationTest4MQ { | |||
PubKey pubKey0 = KeyGenCommand.decodePubKey(IntegrationBase.PUB_KEYS[0]); | |||
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); | |||
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); | |||
BlockchainService blockchainService = gwsrvFact.getBlockchainService(); | |||
@@ -15,7 +15,7 @@ import org.junit.Test; | |||
import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -145,7 +145,7 @@ public class IntegrationTestAll4Redis { | |||
PubKey pubKey2 = KeyGenCommand.decodePubKey(PUB_KEYS[2]); | |||
PubKey pubKey3 = KeyGenCommand.decodePubKey(PUB_KEYS[3]); | |||
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); | |||
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); | |||
testWriteBatchTransactions(gateway0, adminKey, ledgers[0]); | |||
@@ -202,7 +202,7 @@ public class IntegrationTestAll4Redis { | |||
} | |||
// 测试一个区块包含多个交易的写入情况,并验证写入结果; | |||
private void testWriteBatchTransactions(GatewayTestRunner gateway, CryptoKeyPair adminKey, | |||
private void testWriteBatchTransactions(GatewayTestRunner gateway, AsymmetricKeypair adminKey, | |||
LedgerRepository ledgerRepository) { | |||
// 连接网关; | |||
GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); | |||
@@ -257,7 +257,7 @@ public class IntegrationTestAll4Redis { | |||
return; | |||
} | |||
private void testSDK(GatewayTestRunner gateway, CryptoKeyPair adminKey, LedgerRepository ledgerRepository) { | |||
private void testSDK(GatewayTestRunner gateway, AsymmetricKeypair adminKey, LedgerRepository ledgerRepository) { | |||
// 连接网关; | |||
GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); | |||
BlockchainService bcsrv = gwsrvFact.getBlockchainService(); | |||
@@ -271,7 +271,7 @@ public class IntegrationTestAll4Redis { | |||
} | |||
private void testSDK_InsertData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
private void testSDK_InsertData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
Bytes dataAccountAddress, LedgerRepository ledgerRepository) { | |||
// 在本地定义注册账号的 TX; | |||
@@ -315,7 +315,7 @@ public class IntegrationTestAll4Redis { | |||
} | |||
} | |||
private BlockchainKeyPair testSDK_RegisterDataAccount(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private BlockchainKeyPair testSDK_RegisterDataAccount(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, LedgerRepository ledgerRepository) { | |||
// 注册数据账户,并验证最终写入; | |||
BlockchainKeyPair dataAccount = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -350,7 +350,7 @@ public class IntegrationTestAll4Redis { | |||
return dataAccount; | |||
} | |||
private BlockchainKeyPair testSDK_RegisterUser(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private BlockchainKeyPair testSDK_RegisterUser(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, LedgerRepository ledgerRepository) { | |||
// 注册用户,并验证最终写入; | |||
BlockchainKeyPair user = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -390,7 +390,7 @@ public class IntegrationTestAll4Redis { | |||
} | |||
} | |||
private LedgerBlock testSDK_Contract(CryptoKeyPair adminKey, HashDigest ledgerHash, | |||
private LedgerBlock testSDK_Contract(AsymmetricKeypair adminKey, HashDigest ledgerHash, | |||
BlockchainService blockchainService, LedgerRepository ledgerRepository) { | |||
System.out.println("adminKey=" + AddressEncoding.generateAddress(adminKey.getPubKey())); | |||
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -442,7 +442,7 @@ public class IntegrationTestAll4Redis { | |||
return block; | |||
} | |||
private void testContractExe(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
private void testContractExe(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainKeyPair userKey, | |||
BlockchainService blockchainService, LedgerRepository ledgerRepository) { | |||
LedgerInfo ledgerInfo = blockchainService.getLedger(ledgerHash); | |||
LedgerBlock previousBlock = blockchainService.getBlock(ledgerHash, ledgerInfo.getLatestBlockHeight() - 1); | |||
@@ -474,7 +474,7 @@ public class IntegrationTestAll4Redis { | |||
// 验证合约中的赋值,外部可以获得; | |||
DataAccountSet dataAccountSet = ledgerRepository.getDataAccountSet(backgroundLedgerBlock); | |||
CryptoKeyPair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); | |||
AsymmetricKeypair key = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); | |||
PubKey pubKey = key.getPubKey(); | |||
Bytes dataAddress = AddressEncoding.generateAddress(pubKey); | |||
assertEquals(dataAddress, dataAccountSet.getDataAccount(dataAddress).getAddress()); | |||
@@ -489,7 +489,7 @@ public class IntegrationTestAll4Redis { | |||
// assertEquals(userAddress, userAccountSet.getUser(userAddress).getAddress()); | |||
} | |||
private void prepareContractData(CryptoKeyPair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
private void prepareContractData(AsymmetricKeypair adminKey, HashDigest ledgerHash, BlockchainService blockchainService, | |||
LedgerRepository ledgerRepository) { | |||
// 定义交易; | |||
@@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSON; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -126,7 +126,7 @@ public class IntegrationTestDataAccount { | |||
PrivKey privkey0 = KeyGenCommand.decodePrivKeyWithRawPassword(LedgerInitializeWeb4SingleStepsTest.PRIV_KEYS[0], | |||
LedgerInitializeWeb4SingleStepsTest.PASSWORD); | |||
PubKey pubKey0 = KeyGenCommand.decodePubKey(LedgerInitializeWeb4SingleStepsTest.PUB_KEYS[0]); | |||
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); | |||
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); | |||
// regist data account | |||
Bytes dataAddr = registDataAccount(gateway0, adminKey, context); | |||
@@ -138,7 +138,7 @@ public class IntegrationTestDataAccount { | |||
testConsistencyAmongNodes(context); | |||
} | |||
private Bytes registDataAccount(GatewayTestRunner gateway, CryptoKeyPair adminKey, IntegratedContext context) { | |||
private Bytes registDataAccount(GatewayTestRunner gateway, AsymmetricKeypair adminKey, IntegratedContext context) { | |||
// 连接网关; | |||
GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); | |||
BlockchainService blockchainService = gwsrvFact.getBlockchainService(); | |||
@@ -173,7 +173,7 @@ public class IntegrationTestDataAccount { | |||
} | |||
// 通过调用SDK->GATEWAY,测试一个区块包含多个交易时的写入情况,并验证写入结果; | |||
private void testAddKvOpToDataAccount(GatewayTestRunner gateway, CryptoKeyPair adminKey, IntegratedContext context, | |||
private void testAddKvOpToDataAccount(GatewayTestRunner gateway, AsymmetricKeypair adminKey, IntegratedContext context, | |||
Bytes dataAddr) { | |||
GatewayServiceFactory gwsrvFact = GatewayServiceFactory.connect(gateway.getServiceAddress()); | |||
@@ -335,7 +335,7 @@ public class IntegrationTestDataAccount { | |||
node0.setConsensusSettings(csProps); | |||
node0.setLedgerManager(nodeCtx0.getLedgerManager()); | |||
node0.setStorageDB(nodeCtx0.getStorageDB()); | |||
node0.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(0).getPubKey(), privkey0)); | |||
node0.setBindingConfig(bindingConfig0); | |||
context.addNode(node0); | |||
@@ -343,7 +343,7 @@ public class IntegrationTestDataAccount { | |||
node1.setConsensusSettings(csProps); | |||
node1.setLedgerManager(nodeCtx1.getLedgerManager()); | |||
node1.setStorageDB(nodeCtx1.getStorageDB()); | |||
node1.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(1).getPubKey(), privkey1)); | |||
node1.setBindingConfig(bindingConfig1); | |||
context.addNode(node1); | |||
@@ -351,7 +351,7 @@ public class IntegrationTestDataAccount { | |||
node2.setConsensusSettings(csProps); | |||
node2.setLedgerManager(nodeCtx2.getLedgerManager()); | |||
node2.setStorageDB(nodeCtx2.getStorageDB()); | |||
node2.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(2).getPubKey(), privkey2)); | |||
node2.setBindingConfig(bindingConfig2); | |||
context.addNode(node2); | |||
@@ -359,7 +359,7 @@ public class IntegrationTestDataAccount { | |||
node3.setConsensusSettings(csProps); | |||
node3.setLedgerManager(nodeCtx3.getLedgerManager()); | |||
node3.setStorageDB(nodeCtx3.getStorageDB()); | |||
node3.setPartiKeyPair(new CryptoKeyPair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setPartiKeyPair(new AsymmetricKeypair(initSetting.getConsensusParticipant(3).getPubKey(), privkey3)); | |||
node3.setBindingConfig(bindingConfig3); | |||
context.addNode(node3); | |||
@@ -8,7 +8,7 @@ | |||
*/ | |||
package test.com.jd.blockchain.intgr.batch.bftsmart; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -181,7 +181,7 @@ public class BftsmartLedgerInit { | |||
PubKey pubKey0 = KeyGenCommand.decodePubKey(BftsmartConfig.PUB_KEY[0]); | |||
CryptoKeyPair adminKey = new CryptoKeyPair(pubKey0, privkey0); | |||
AsymmetricKeypair adminKey = new AsymmetricKeypair(pubKey0, privkey0); | |||
BlockchainService blockchainService = gwsrvFact.getBlockchainService(); | |||
@@ -13,7 +13,7 @@ import static com.jd.blockchain.tools.keygen.KeyGenCommand.encodePubKey; | |||
import org.junit.Test; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.SignatureFunction; | |||
import com.jd.blockchain.utils.codec.Base58Utils; | |||
@@ -38,7 +38,7 @@ public class BftsmartTestBase { | |||
public void newUsers() { | |||
SignatureFunction signFunc = CryptoServiceProviders.getSignatureFunction("ED25519"); | |||
for (int i = 0; i < userSize; i++) { | |||
CryptoKeyPair kp = signFunc.generateKeyPair(); | |||
AsymmetricKeypair kp = signFunc.generateKeypair(); | |||
String base58PubKey = encodePubKey(kp.getPubKey()); | |||
@@ -19,7 +19,7 @@ import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.AddressEncoding; | |||
import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
@@ -211,9 +211,9 @@ public class LedgerInitializeTest { | |||
private LedgerInitProcess initProcess; | |||
private CryptoKeyPair partiKey; | |||
private AsymmetricKeypair partiKey; | |||
public CryptoKeyPair getPartiKey() { | |||
public AsymmetricKeypair getPartiKey() { | |||
return partiKey; | |||
} | |||
@@ -237,7 +237,7 @@ public class LedgerInitializeTest { | |||
ConsensusSettings csProps, ConsensusProvider csProvider, DBConnectionConfig dbConnConfig, | |||
Prompter prompter) { | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -258,7 +258,7 @@ public class LedgerInitializeTest { | |||
cryptoSetting.setAutoVerifyHash(autoVerifyHash); | |||
cryptoSetting.setHashAlgorithm(CryptoServiceProviders.getAlgorithm("SHA256")); | |||
partiKey = new CryptoKeyPair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
partiKey = new AsymmetricKeypair(setting.getConsensusParticipant(0).getPubKey(), privKey); | |||
ThreadInvoker<HashDigest> invoker = new ThreadInvoker<HashDigest>() { | |||
@Override | |||
@@ -16,7 +16,7 @@ import org.springframework.core.io.ClassPathResource; | |||
import com.jd.blockchain.consensus.ConsensusProvider; | |||
import com.jd.blockchain.consensus.ConsensusProviders; | |||
import com.jd.blockchain.consensus.ConsensusSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.ledger.BlockchainKeyGenerator; | |||
@@ -63,7 +63,7 @@ public class LedgerBlockGeneratingTest { | |||
test(ledgerHash, node.getPartiKey(), ledgerManager, opHandler, 1000, 5); | |||
} | |||
private static void test(HashDigest ledgerHash, CryptoKeyPair adminKey, LedgerManager ledgerManager, | |||
private static void test(HashDigest ledgerHash, AsymmetricKeypair adminKey, LedgerManager ledgerManager, | |||
DefaultOperationHandleRegisteration opHandler, int batchSize, int batchCount) { | |||
LedgerRepository ledger = ledgerManager.getLedger(ledgerHash); | |||
long height = ledger.getLatestBlockHeight(); | |||
@@ -106,7 +106,7 @@ public class LedgerBlockGeneratingTest { | |||
} | |||
private static List<TransactionRequest> prepareUserRegisterRequests(HashDigest ledgerHash, int count, | |||
CryptoKeyPair adminKey) { | |||
AsymmetricKeypair adminKey) { | |||
List<TransactionRequest> txList = new ArrayList<>(); | |||
for (int i = 0; i < count; i++) { | |||
TxBuilder txbuilder = new TxBuilder(ledgerHash); | |||
@@ -21,7 +21,7 @@ import com.jd.blockchain.binaryproto.BinaryEncodingUtils; | |||
import com.jd.blockchain.capability.settings.CapabilitySettings; | |||
import com.jd.blockchain.consensus.mq.factory.MsgQueueFactory; | |||
import com.jd.blockchain.consensus.mq.producer.MsgQueueProducer; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.ledger.BlockchainIdentity; | |||
import com.jd.blockchain.ledger.BlockchainKeyGenerator; | |||
@@ -317,7 +317,7 @@ public class RemoteTransactionService { | |||
return txSerializeBytes; | |||
} | |||
private TransactionRequest userRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) { | |||
private TransactionRequest userRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) { | |||
TxBuilder txbuilder = new TxBuilder(ledgerHash); | |||
BlockchainKeyPair userKey = BlockchainKeyGenerator.getInstance().generate(); | |||
txbuilder.users().register(userKey.getIdentity()); | |||
@@ -326,7 +326,7 @@ public class RemoteTransactionService { | |||
return reqBuilder.buildRequest(); | |||
} | |||
private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey, boolean isSave) { | |||
private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey, boolean isSave) { | |||
TxBuilder txbuilder = new TxBuilder(ledgerHash); | |||
BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); | |||
BlockchainIdentity identity = dataAccountKey.getIdentity(); | |||
@@ -339,7 +339,7 @@ public class RemoteTransactionService { | |||
return reqBuilder.buildRequest(); | |||
} | |||
private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, CryptoKeyPair adminKey) { | |||
private TransactionRequest dataAccountRegisterRequest(HashDigest ledgerHash, AsymmetricKeypair adminKey) { | |||
TxBuilder txbuilder = new TxBuilder(ledgerHash); | |||
BlockchainKeyPair dataAccountKey = BlockchainKeyGenerator.getInstance().generate(); | |||
BlockchainIdentity identity = dataAccountKey.getIdentity(); | |||
@@ -350,7 +350,7 @@ public class RemoteTransactionService { | |||
return reqBuilder.buildRequest(); | |||
} | |||
private TransactionRequest kvStorageRequest(Bytes address, HashDigest ledgerHash, CryptoKeyPair adminKey) { | |||
private TransactionRequest kvStorageRequest(Bytes address, HashDigest ledgerHash, AsymmetricKeypair adminKey) { | |||
TxBuilder txbuilder = new TxBuilder(ledgerHash); | |||
long currValue = keyPrefix.getAndIncrement(); | |||
txbuilder.dataAccount(address).set("key-" + currValue + "-" + System.currentTimeMillis(), | |||
@@ -13,7 +13,7 @@ import com.jd.blockchain.capability.settings.CapabilitySettings; | |||
import com.jd.blockchain.consensus.action.ActionResponse; | |||
import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusSettings; | |||
import com.jd.blockchain.consensus.bftsmart.BftsmartNodeSettings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -118,7 +118,7 @@ public class SettingsInit { | |||
// 处理用户 | |||
PrivKey privKey = KeyGenCommand.decodePrivKeyWithRawPassword(settings.getPrivKey(), settings.getPwd()); | |||
PubKey pubKey = KeyGenCommand.decodePubKey(settings.getPubKey()); | |||
CapabilitySettings.adminKey = new CryptoKeyPair(pubKey, privKey); | |||
CapabilitySettings.adminKey = new AsymmetricKeypair(pubKey, privKey); | |||
} | |||
private static class Settings { | |||
@@ -8,7 +8,7 @@ | |||
*/ | |||
package com.jd.blockchain.capability.settings; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.HashDigest; | |||
/** | |||
@@ -41,7 +41,7 @@ public class CapabilitySettings { | |||
public static HashDigest ledgerHash; | |||
public static CryptoKeyPair adminKey; | |||
public static AsymmetricKeypair adminKey; | |||
public static final String settingsConf = "settings.conf"; | |||
} |
@@ -8,7 +8,7 @@ import java.util.List; | |||
import javax.crypto.SecretKey; | |||
import com.jd.blockchain.crypto.CryptoKeyPair; | |||
import com.jd.blockchain.crypto.AsymmetricKeypair; | |||
import com.jd.blockchain.crypto.CryptoServiceProviders; | |||
import com.jd.blockchain.crypto.PrivKey; | |||
import com.jd.blockchain.crypto.PubKey; | |||
@@ -104,7 +104,7 @@ public class KeyGenCommand { | |||
* @param outputDir | |||
*/ | |||
private static void generateKeyPair(String name, String outputDir, String localConfPath) { | |||
CryptoKeyPair kp = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeyPair(); | |||
AsymmetricKeypair kp = CryptoServiceProviders.getSignatureFunction("ED25519").generateKeypair(); | |||
String base58PubKey = encodePubKey(kp.getPubKey()); | |||