Skip to content

Commit

Permalink
Merge pull request #335 from youwenbusi/develop
Browse files Browse the repository at this point in the history
pre-release
  • Loading branch information
youwenbusi committed Aug 12, 2022
2 parents d14f204 + 7413b30 commit 3762667
Show file tree
Hide file tree
Showing 33 changed files with 79 additions and 111 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.5-rc.1-SNAPSHOT
1.8.5-rc.8-SNAPSHOT
1 change: 0 additions & 1 deletion authorityIssuer.address

This file was deleted.

21 changes: 15 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ List logger = [

// junit test
List junit = [
"junit:junit:4.12"
"junit:junit:4.13.1"
]

List apache_commons = [
Expand All @@ -116,6 +116,11 @@ List json = [
"com.networknt:json-schema-validator:1.0.71",
]

def gson_version = "2.8.9"
List gson = [
"com.google.code.gson:gson:$gson_version"
]

List mysql_driver = [
"mysql:mysql-connector-java:8.0.20", // todo runtime
"org.apache.commons:commons-dbcp2:2.5.0"
Expand All @@ -136,11 +141,11 @@ List rpc = [
]

List pdfbox = [
"org.apache.pdfbox:pdfbox:2.0.16"
"org.apache.pdfbox:pdfbox:2.0.24"
]

List protobuf = [
"com.google.protobuf:protobuf-java:3.9.1"
"com.google.protobuf:protobuf-java:3.19.2"
]

List caffeine = [
Expand All @@ -160,11 +165,15 @@ configurations {
all*.exclude group: "io.netty", module: "netty-tcnative"
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
localDeps 'org.projectlombok:lombok:1.18.10'
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, redisson, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.3.0-rc.2-SNAPSHOT")
compile logger, lombok, apache_commons, json, mysql_driver, redisson, zxing, rpc, pdfbox, protobuf, caffeine, oval, gson
compile("com.webank:weid-contract-java:1.3.0-rc.4-SNAPSHOT")

compile fileTree(dir: 'lib', include: '*.jar')
implementation 'com.google.guava:guava:31.1-jre'
Expand All @@ -173,7 +182,7 @@ dependencies {
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.15'
annotationProcessor lombok

testCompile logger, lombok, apache_commons, json, junit, jmockit, rpc, pdfbox, protobuf, caffeine, oval, spring
testCompile logger, lombok, apache_commons, json, junit, jmockit, rpc, pdfbox, protobuf, caffeine, oval, spring, gson
testAnnotationProcessor lombok
}
if (gradleVer.startsWith("4")) {
Expand Down
1 change: 0 additions & 1 deletion cptController.address

This file was deleted.

6 changes: 3 additions & 3 deletions dist/conf/fisco.properties.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#######################################################################################################
# #
# fisco bcos version config #
# fisco bcos 2 or 3 version config #
# #
#######################################################################################################
# Version
Expand Down Expand Up @@ -53,8 +53,8 @@ group.id=1
# fisco bcos node cert related config #
# #
#######################################################################################################
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SM2
sdk.sm-crypto=false
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SaM2
sdk.sm-crypto=${SDK_SM_CRYPTO}
# fisco-bcos sdk cert path contains[ca.crt,sdk.crt,sdk.key]
# if sdk.sm-crypto is true, contains [gm] directory, and gm dir contains [gmca.crt,gmsdk.crt,gmsdk.key,gmensdk.crt,gmensdk.key]
sdk.cert-path=conf
Expand Down
1 change: 0 additions & 1 deletion evidenceController.address

This file was deleted.

2 changes: 1 addition & 1 deletion hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0x8dbf78b289f33000e57e80fc15d415b40f2cfe5688d7a92f07393b97606aeed7
0x74ca478cbab6dd09a36da3f3bf56e433174e983ec38d5bd0d3e13593f72ae261
2 changes: 1 addition & 1 deletion public_key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5686332858406600098574930615286920155179124750677701187633916230205742334882670952535475018419229666394535946783087534972161773024961235927824774898541110
13079093397463814932731720163442777403208788175453836227824139092404945067394266611910031425181012754616377192193136435818972874637291518463471522281921222
1 change: 0 additions & 1 deletion specificIssuer.address

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ private static String initCryptoKeyPair(String inputPrivateKey) {
byte[] pubBytes = Numeric.hexStringToByteArray(cryptoKeyPair.getHexPublicKey());
String privateKey = new BigInteger(1, priBytes).toString(10);
String publicKey = new BigInteger(1, pubBytes).toString(10);
writeAddressToFile(publicKey, "ecdsa_key.pub");
writeAddressToFile(privateKey, "ecdsa_key");
writeAddressToFile(publicKey, "public_key");
writeAddressToFile(privateKey, "private_key");
}

//if (credentials == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private static boolean initCryptoKeyPair(String inputPrivateKey) {
byte[] pubBytes = Numeric.hexStringToByteArray(cryptoKeyPair.getHexPublicKey());
String privateKey = new BigInteger(1, priBytes).toString(10);
String publicKey = new BigInteger(1, pubBytes).toString(10);
writeAddressToFile(publicKey, "ecdsa_key.pub");
writeAddressToFile(privateKey, "ecdsa_key");
writeAddressToFile(publicKey, "public_key");
writeAddressToFile(privateKey, "private_key");
return true;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ private static void registerToCns(
FiscoConfig fiscoConfig,
boolean instantEnable
) {
String privateKey = AddressProcess.getAddressFromFile("ecdsa_key");
String privateKey = AddressProcess.getAddressFromFile("private_key");
WeIdPrivateKey weIdPrivate = new WeIdPrivateKey();
weIdPrivate.setPrivateKey(privateKey);
registerAddress(weIdPrivate, fiscoConfig, instantEnable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private static String initCryptoKeyPair(String inputPrivateKey) {
byte[] pubBytes = Numeric.hexStringToByteArray(cryptoKeyPair.getHexPublicKey());
String privateKey = new BigInteger(1, priBytes).toString(10);
String publicKey = new BigInteger(1, pubBytes).toString(10);
writeAddressToFile(publicKey, "ecdsa_key.pub");
writeAddressToFile(privateKey, "ecdsa_key");
writeAddressToFile(publicKey, "public_key");
writeAddressToFile(privateKey, "private_key");
}

//if (credentials == null) {
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/com/webank/weid/service/fisco/v2/WeServerV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,11 @@ private void initAmopTopic(ConfigProperty configProperty, FiscoConfig fiscoConfi
AmopTopic amopTopic = new AmopTopic();
amopTopic.setTopicName(fiscoConfig.getAmopId());
// 配置amop用到的私钥文件,写入的是public keys的路径和p12私钥的路径及p12密码
// amopTopic.setPublicKeys(Arrays.asList(fiscoConfig.getAmopPubPath()));
// amopTopic.setPrivateKey(fiscoConfig.getPrivateKey());
// amopTopic.setPassword(fiscoConfig.getAmopP12Password());

amopTopic.setPublicKeys(Arrays.asList("E:\\weid-afee\\WeIdentity\\out\\production\\resources\\consumer_public_key.pem"));
amopTopic.setPrivateKey("E:\\weid-afee\\WeIdentity\\out\\production\\resources\\consumer_private_key.p12");
amopTopic.setPublicKeys(Arrays.asList(fiscoConfig.getAmopPubPath()));
amopTopic.setPrivateKey(fiscoConfig.getPrivateKey());

//amopTopic.setPublicKeys(Arrays.asList("E:\\weid-afee\\WeIdentity\\out\\production\\resources\\consumer_public_key.pem"));
//amopTopic.setPrivateKey("E:\\weid-afee\\WeIdentity\\out\\production\\resources\\consumer_private_key.p12");
amopTopic.setPassword(fiscoConfig.getAmopP12Password());
List<AmopTopic> amop = new ArrayList<AmopTopic>();
amop.add(amopTopic);
Expand Down Expand Up @@ -287,9 +285,9 @@ private void initCryptoMaterial(ConfigProperty configProperty, FiscoConfig fisco
cryptoMaterial.put("useSMCrypto", fiscoConfig.getSdkSMCrypto());
cryptoMaterial.put("certPath", fiscoConfig.getSdkCertPath());
logger.info("path:{} before", cryptoMaterial.get("certPath"));
cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\test\\resources");
cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\production\\resources");
logger.info("path:{}", cryptoMaterial.get("certPath"));
//cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\test\\resources");
//cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\production\\resources");
//logger.info("path:{}", cryptoMaterial.get("certPath"));
// cryptoMaterial.put("certPath", this.getClass().getResource("classpath:").getPath());
// cryptoMaterial.put("caCert",
// FiscoConfig.class.getResource("classpath:" + fiscoConfig.getV2CaCrtPath()));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/webank/weid/service/fisco/v3/WeServerV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Class<?> getWeb3jClass() {

@Override
public CryptoKeyPair getCredentials() {
Client client = this.getWeb3j(fiscoConfig.getGroupId());
Client client = this.getWeb3j();
return client.getCryptoSuite().getCryptoKeyPair();
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public void onResponse(Response response) {

@Override
public int getBlockNumber() {
return this.getWeb3j(fiscoConfig.getGroupId()).getBlockNumber().getBlockNumber().intValue();
return this.getWeb3j().getBlockNumber().getBlockNumber().intValue();
}

/**
Expand Down Expand Up @@ -331,10 +331,10 @@ private void initCryptoMaterial(ConfigProperty configProperty, FiscoConfig fisco
cryptoMaterial.put("useSMCrypto", fiscoConfig.getSdkSMCrypto());
cryptoMaterial.put("certPath", fiscoConfig.getSdkCertPath());
logger.info("path:{} before", cryptoMaterial.get("certPath"));
cryptoMaterial.put("certPath", "D:\\projects\\weid\\WeIdentity\\out\\test\\resources");
logger.info("path:{}", cryptoMaterial.get("certPath"));
cryptoMaterial.put("certPath", "D:\\projects\\weid\\WeIdentity\\out\\production\\resources");
logger.info("[initThreadPool] the cryptoMaterial: {}.", cryptoMaterial);
//cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\test\\resources");
//logger.info("path:{}", cryptoMaterial.get("certPath"));
//cryptoMaterial.put("certPath", "E:\\weid-afee\\WeIdentity\\out\\production\\resources");
//logger.info("[initThreadPool] the cryptoMaterial: {}.", cryptoMaterial);
configProperty.setCryptoMaterial(cryptoMaterial);
}

Expand Down Expand Up @@ -380,15 +380,15 @@ private void initAmopCallBack(FiscoConfig fiscoConfig) {
}

private void initCnsService() {
Client client = this.getWeb3j(fiscoConfig.getGroupId());
Client client = this.getWeb3j();
this.bfsService = new BFSService(client, client.getCryptoSuite().getCryptoKeyPair());
}



@Override
public Set<String> getGroupList() {
List<String> groupStrList = bcosSdk.getClient().getGroupList().getResult().getGroupList();
List<String> groupStrList = this.getWeb3j().getGroupList().getResult().getGroupList();
Set<String> groupList = new HashSet<>(groupStrList);
return groupList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,10 @@
import com.webank.weid.suite.cache.CacheNode;
import com.webank.weid.util.DataToolUtils;
import com.webank.weid.util.WeIdUtils;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.fisco.bcos.sdk.v3.client.protocol.model.JsonTransactionResponse;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.client.protocol.model.JsonTransactionResponse;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosBlock;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosBlock.TransactionResult;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.Bytes32;
Expand All @@ -42,6 +33,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigInteger;
import java.util.*;

/**
* EvidenceServiceEngine calls evidence contract which runs on FISCO BCOS 2.0.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.apache.commons.lang3.StringUtils;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.v3.client.protocol.model.JsonTransactionResponse;
import org.fisco.bcos.sdk.v3.client.protocol.model.Transaction;
//import org.fisco.bcos.sdk.v3.client.protocol.model.Transaction;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosBlock;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosBlock.TransactionResult;
import org.fisco.bcos.sdk.v3.codec.EventEncoder;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/webank/weid/util/DataToolUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static <T> String serialize(T object) {
* @param privateKey the pass-in privatekey
* @return true if yes, false otherwise
*/
public static String convertPrivateKeyToDefaultWeId(BigInteger privateKey) {
/*public static String convertPrivateKeyToDefaultWeId(BigInteger privateKey) {
return publicKeyStrFromPrivate(privateKey);
// BigInteger publicKey;
// if (encryptType.equals(String.valueOf(EncryptType.ECDSA_TYPE))) {
Expand All @@ -264,7 +264,7 @@ public static String convertPrivateKeyToDefaultWeId(BigInteger privateKey) {
// Keys.getAddress(publicKey)).toString());
// CryptoKeyPair keyPair = createKeyPairFromPrivate(new BigInteger(privateKey));
// return WeIdUtils.convertAddressToWeId(keyPair.getAddress());
}
}*/

/**
* Check whether the String is a valid hash.
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/ecdsa_key

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/ecdsa_key.pub

This file was deleted.

41 changes: 13 additions & 28 deletions src/main/resources/fisco.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ issuer.contractaddress=
evidence.contractaddress=
specificissuer.contractaddress=

# This variable is used to distinguish the environment. You can use "dev" to set the development environment,
# This variable is used to distinguish the environment. You can use "dev" to set the development environment,
# "stg" to set the test environment, "prd" to set the production environment,
# If you do not set it, the system will use allOrg as the environment by default.
# If you do not set it, the system will use allOrg as the environment by default.
# It is not recommended. Production use default configuration
cns.profile.active=prd140
cns.profile.active=2

#######################################################################################################
# #
Expand All @@ -38,13 +38,7 @@ web3sdk.core-pool-size=100
web3sdk.max-pool-size=200
web3sdk.queue-capacity=1000
web3sdk.keep-alive-seconds=60
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SM2
sdk.sm-crypto=true
sdk.cert-path=conf
# amop public key of pem and private key of p12 configuration
amop.pub-path=conf/amop/consumer_public_key.pem
amop.pri-path=conf/amop/consumer_private_key.p12
amop.p12-password=123456


#######################################################################################################
# #
Expand All @@ -54,27 +48,18 @@ amop.p12-password=123456
# Fisco-Bcos 2.x params, including Group ID and Encrypt Type
group.id=1


#######################################################################################################
# #
# fisco bcos node cert related config #
# #
#######################################################################################################
# config files params
v1.ca-crt-path=ca.crt
v1.client-crt-password=123456
v1.client-key-store-path=client.keystore
v1.key-store-password=123456



v2.ca-crt-path=ca.crt
v2.node-crt-path=node.crt
v2.node-key-path=node.key
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SM2
sdk.sm-crypto=true
# fisco-bcos sdk cert path contains[ca.crt,sdk.crt,sdk.key]
# if sdk.sm-crypto is true, contains [gm] directory, and gm dir contains [gmca.crt,gmsdk.crt,gmsdk.key,gmensdk.crt,gmensdk.key]
sdk.cert-path=conf

# gm
gm.ca-crt-path=gmca.crt
gm.sdk-crt-path=gmsdk.crt
gm.sdk-key-path=gmsdk.key
gmen.sdk-crt-path=gmensdk.crt
gmen.sdk-key-path=gmensdk.key
# amop public key of pem and private key of p12 configuration
amop.pub-path=conf/amop/consumer_public_key.pem
amop.pri-path=conf/amop/consumer_private_key.p12
amop.p12-password=123456
2 changes: 1 addition & 1 deletion src/main/resources/fisco.properties.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ group.id=1
# fisco bcos node cert related config #
# #
#######################################################################################################
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SM2
# Fisco-Bcos sdk SSL encrypt type, false:ECDSA, true:SaM2
sdk.sm-crypto=${SDK_SM_CRYPTO}
# fisco-bcos sdk cert path contains[ca.crt,sdk.crt,sdk.key]
# if sdk.sm-crypto is true, contains [gm] directory, and gm dir contains [gmca.crt,gmsdk.crt,gmsdk.key,gmensdk.crt,gmensdk.key]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.math.BigInteger;
import java.util.List;

import com.webank.weid.util.WeIdUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keystore.KeyTool;
Expand Down Expand Up @@ -152,7 +153,7 @@ public void testGetAllAuthorityIssuerList_removeListThenQuery() {

Assert.assertEquals(ErrorCode.SUCCESS.getCode(), response.getErrorCode().intValue());
List<AuthorityIssuer> authorityIssuers = response.getResult();
String sdkWeId = DataToolUtils.convertPrivateKeyToDefaultWeId(new BigInteger(privateKey));
String sdkWeId = WeIdUtils.getWeIdFromPrivateKey(privateKey);

for (int i = 0; i < authorityIssuers.size(); i++) {
String weId = authorityIssuers.get(i).getWeId();
Expand Down

0 comments on commit 3762667

Please sign in to comment.