Skip to content

Commit

Permalink
Merge pull request #292 from WeBankFinTech/release/1.8.0
Browse files Browse the repository at this point in the history
Release/1.8.0
  • Loading branch information
junqizhang-dev authored Jan 26, 2021
2 parents 6c28457 + e76f1d0 commit 012c95a
Show file tree
Hide file tree
Showing 42 changed files with 478 additions and 163 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### V1.7.0
Features:
1. FISCO BCOS 1.3.x support is fully removed - please use the FISCO BCOS 2.x node version respectively.
2. Evidence and WeIdDocument query performance improved due to support batch type blockchain node data lookup.
3. Authority Issuer can be registered by any WeID while only administrator can recognize.
4. Greatly enhanced WeID-Build-Tools functionalities.
5. Persistence now supports Redis as storage layer.

### V1.6.3-hotfix-1 (2020-08-26)
- Bugfixes:
1. Use batch block transaction receipts getter to improve evidence performance.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.1
1.8.0
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ 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.2.28") {
compile("com.webank:weid-contract-java:1.2.29") {
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
compile fileTree(dir: 'lib', include: '*.jar')
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_CN/docs/weidentity-java-sdk-doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13752,7 +13752,7 @@ com.webank.weid.protocol.base.CredentialPojo
// Enforce a Register/Update system CPT first
WeIdAuthentication sdkAuthen = new WeIdAuthentication();
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(privateKey);
String keyWeId = WeIdUtils
.convertAddressToWeId(new Address(Keys.getAddress(keyPair)).toString());
sdkAuthen.setWeId(keyWeId);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/webank/weid/config/FiscoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ public class FiscoConfig {
@NotNull(message = "the v2.node-key-path is undefined")
@NotEmpty(message = "the value of v2.node-key-path is null")
private String v2NodeKeyPath;

@NotNull(message = "the gm.ca-crt-path is undefined")
@NotEmpty(message = "the value of gm.ca-crt-path is null")
private String gmCaCrtPath;

@NotNull(message = "the gm.sdk-crt-path is undefined")
@NotEmpty(message = "the value of gm.sdk-crt-path is null")
private String gmSdkCrtPath;

@NotNull(message = "the gm.sdk-key-path is undefined")
@NotEmpty(message = "the value of gm.sdk-key-path is null")
private String gmSdkKeyPath;

@NotNull(message = "the gmen.sdk-crt-path is undefined")
@NotEmpty(message = "the value of gmen.sdk-crt-path is null")
private String gmenSdkCrtPath;

@NotNull(message = "the gmen.sdk-key-path is undefined")
@NotEmpty(message = "the value of gmen.sdk-key-path is null")
private String gmenSdkKeyPath;

@NotNull(message = "the blockchain.orgid is undefined")
@NotEmpty(message = "the value of blockchain.orgid is null")
Expand Down Expand Up @@ -174,6 +194,11 @@ public boolean load() {
v2CaCrtPath = PropertyUtils.getProperty("v2.ca-crt-path");
v2NodeCrtPath = PropertyUtils.getProperty("v2.node-crt-path");
v2NodeKeyPath = PropertyUtils.getProperty("v2.node-key-path");
gmCaCrtPath = PropertyUtils.getProperty("gm.ca-crt-path");
gmSdkCrtPath = PropertyUtils.getProperty("gm.sdk-crt-path");
gmSdkKeyPath = PropertyUtils.getProperty("gm.sdk-key-path");
gmenSdkCrtPath = PropertyUtils.getProperty("gmen.sdk-crt-path");
gmenSdkKeyPath = PropertyUtils.getProperty("gmen.sdk-key-path");
currentOrgId = PropertyUtils.getProperty("blockchain.orgid");
amopId = PropertyUtils.getProperty("amop.id");
cnsContractFollow = PropertyUtils.getProperty("cns.contract.follow");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/webank/weid/protocol/cpt/Cpt109.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.webank.weid.protocol.cpt;

import com.github.reinert.jjschema.Attributes;

import lombok.Data;

/**
Expand All @@ -28,6 +30,8 @@
*/

@Data
@Attributes(title = "Trusted Timestamp",
description = "Trusted Timestamp from authorized 3rd-party, or chain consensus")
public class Cpt109 {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.webank.weid.protocol.response;

import java.util.List;

import lombok.Data;

/**
* get WeId and errorCode by pubkeyList response.
*
*/
@Data
public class WeIdListResult {

private List<String> weIdList;

private List<Integer> errorCodeList;
}
6 changes: 6 additions & 0 deletions src/main/java/com/webank/weid/rpc/AuthorityIssuerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,10 @@ ResponseData<List<String>> getAllSpecificTypeIssuerList(
* @return WeID
*/
ResponseData<String> getWeIdByOrgId(String orgId);

/**
* get the issuer count.
* @return the all issuer
*/
ResponseData<Integer> getIssuerCount();
}
18 changes: 18 additions & 0 deletions src/main/java/com/webank/weid/rpc/CptService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.webank.weid.rpc;

import java.util.List;

import com.webank.wedpr.selectivedisclosure.CredentialTemplateEntity;

import com.webank.weid.protocol.base.Cpt;
Expand Down Expand Up @@ -101,4 +103,20 @@ public interface CptService {
* @return The updated CPT info
*/
ResponseData<CredentialTemplateEntity> queryCredentialTemplate(Integer cptId);

/**
* Get CPTIDS from chain.
*
* @param startPos start position
* @param num batch number
* @return CPTID list
*/
ResponseData<List<Integer>> getCptIdList(Integer startPos, Integer num);

/**
* Get CPT count.
*
* @return the cpt count
*/
ResponseData<Integer> getCptCount();
}
7 changes: 7 additions & 0 deletions src/main/java/com/webank/weid/rpc/PolicyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,11 @@ ResponseData<Integer> registerPresentationPolicy(List<Integer> claimPolicyIdList
* @return claim policy list
*/
ResponseData<List<Integer>> getAllClaimPolicies(Integer startPos, Integer num);

/**
* Get Policy count.
*
* @return the Policy count
*/
ResponseData<Integer> getPolicyCount();
}
8 changes: 8 additions & 0 deletions src/main/java/com/webank/weid/rpc/WeIdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.webank.weid.protocol.request.ServiceArgs;
import com.webank.weid.protocol.response.CreateWeIdDataResult;
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.protocol.response.WeIdListResult;


/**
Expand Down Expand Up @@ -219,4 +220,11 @@ ResponseData<List<WeIdPojo>> getWeIdList(
* @return total weid
*/
ResponseData<Integer> getWeIdCount();

/**
* get WeID list by pubKey list.
* @param pubKeyList the pubKey list
* @return return the WeIDListResult
*/
ResponseData<WeIdListResult> getWeIdListByPubKeyList(List<WeIdPublicKey> pubKeyList);
}
35 changes: 29 additions & 6 deletions src/main/java/com/webank/weid/service/fisco/WeServerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.fisco.bcos.channel.client.Service;
import org.fisco.bcos.channel.handler.ChannelConnections;
import org.fisco.bcos.channel.handler.GroupChannelConnectionsConfig;
import org.fisco.bcos.web3j.crypto.EncryptType;
import org.fisco.bcos.web3j.protocol.Web3j;
import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -146,12 +147,34 @@ public static GroupChannelConnectionsConfig buildGroupChannelConnectionsConfig(
ChannelConnections channelConnections = new ChannelConnections();
channelConnections.setGroupId(groupId);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
channelConnections
.setCaCert(resolver.getResource("classpath:" + fiscoConfig.getV2CaCrtPath()));
channelConnections
.setSslCert(resolver.getResource("classpath:" + fiscoConfig.getV2NodeCrtPath()));
channelConnections
.setSslKey(resolver.getResource("classpath:" + fiscoConfig.getV2NodeKeyPath()));

if (fiscoConfig.getEncryptType().equals(String.valueOf(EncryptType.ECDSA_TYPE))) {
EncryptType encryptType = new EncryptType(EncryptType.ECDSA_TYPE);
channelConnections.setCaCert(
resolver.getResource("classpath:" + fiscoConfig.getV2CaCrtPath()));
channelConnections.setSslCert(
resolver.getResource("classpath:" + fiscoConfig.getV2NodeCrtPath()));
channelConnections.setSslKey(
resolver.getResource("classpath:" + fiscoConfig.getV2NodeKeyPath()));
} else {
EncryptType encryptType = new EncryptType(EncryptType.SM2_TYPE);

// gmca.crt
channelConnections.setGmCaCert(
resolver.getResource("classpath:" + fiscoConfig.getGmCaCrtPath()));
// gmsdk.crt
channelConnections.setGmSslCert(
resolver.getResource("classpath:" + fiscoConfig.getGmSdkCrtPath()));
// gmsdk.key
channelConnections.setGmSslKey(
resolver.getResource("classpath:" + fiscoConfig.getGmSdkKeyPath()));
// gmensdk.crt
channelConnections.setGmEnSslCert(
resolver.getResource("classpath:" + fiscoConfig.getGmenSdkCrtPath()));
// gmensdk.key
channelConnections.setGmEnSslKey(
resolver.getResource("classpath:" + fiscoConfig.getGmenSdkKeyPath()));
}

channelConnections.setConnectionsStr(nodeList);
GroupChannelConnectionsConfig connectionsConfig = new GroupChannelConnectionsConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;

import org.fisco.bcos.channel.client.ChannelPushCallback;
import org.fisco.bcos.channel.client.Service;
import org.fisco.bcos.channel.dto.ChannelRequest;
Expand Down Expand Up @@ -51,6 +52,7 @@
import com.webank.weid.service.fisco.WeServer;
import com.webank.weid.service.fisco.WeServerUtils;
import com.webank.weid.service.impl.base.AmopCommonArgs;
import com.webank.weid.util.DataToolUtils;

public final class WeServerV2 extends WeServer<Web3j, Credentials, Service> {

Expand Down Expand Up @@ -89,8 +91,8 @@ public Credentials getCredentials() {
public Credentials createCredentials(String privateKey) {
Credentials credentials;
try {
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
credentials = Credentials.create(keyPair);
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(new BigInteger(privateKey));
credentials = GenCredential.create(keyPair);
return credentials;
} catch (Exception e) {
throw new PrivateKeyIllegalException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,9 @@ public ResponseData<String> getWeIdByOrgId(String orgId) {
return new ResponseData<>(StringUtils.EMPTY, ErrorCode.AUTHORITY_ISSUER_ERROR);
}
}

@Override
public ResponseData<Integer> getIssuerCount() {
return authEngine.getIssuerCount();
}
}
18 changes: 15 additions & 3 deletions src/main/java/com/webank/weid/service/impl/CptServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.webank.wedpr.selectivedisclosure.CredentialTemplateEntity;
Expand All @@ -29,9 +30,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webank.weid.constant.CredentialConstant;
import com.webank.weid.constant.ErrorCode;
import com.webank.weid.constant.JsonSchemaConstant;
import com.webank.weid.constant.WeIdConstant;
import com.webank.weid.protocol.base.Cpt;
import com.webank.weid.protocol.base.CptBaseInfo;
Expand Down Expand Up @@ -371,7 +370,20 @@ private ErrorCode validateCptJsonSchemaMap(
*/
@Override
public ResponseData<CredentialTemplateEntity> queryCredentialTemplate(Integer cptId) {

return cptServiceEngine.queryCredentialTemplate(cptId);
}


@Override
public ResponseData<List<Integer>> getCptIdList(Integer startPos, Integer num) {
if (startPos < 0 || num < 1) {
return new ResponseData<>(null, ErrorCode.ILLEGAL_INPUT);
}
return cptServiceEngine.getCptIdList(startPos, num, WeIdConstant.CPT_DATA_INDEX);
}

@Override
public ResponseData<Integer> getCptCount() {
return cptServiceEngine.getCptCount(WeIdConstant.CPT_DATA_INDEX);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ public ResponseData<CredentialPojo> addSignature(
return new ResponseData<>(null, ErrorCode.WEID_DOES_NOT_EXIST);
}
String privateKey = callerAuth.getWeIdPrivateKey().getPrivateKey();
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(new BigInteger(privateKey));
String keyWeId = WeIdUtils
.convertAddressToWeId(new Address(Keys.getAddress(keyPair)).toString());
result.setIssuer(keyWeId);
Expand Down Expand Up @@ -1985,7 +1985,7 @@ public ResponseData<CredentialPojo> createTrustedTimestamp(
CredentialPojo credential = new CredentialPojo();
credential.setCptId(CredentialConstant.EMBEDDED_TIMESTAMP_CPT);
String privateKey = weIdAuthentication.getWeIdPrivateKey().getPrivateKey();
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(new BigInteger(privateKey));
String keyWeId = WeIdUtils
.convertAddressToWeId(new Address(Keys.getAddress(keyPair)).toString());
credential.setIssuer(keyWeId);
Expand Down Expand Up @@ -2249,7 +2249,7 @@ public ResponseData<CredentialPojo> createDataAuthToken(
args.setContext(CredentialUtils.getDefaultCredentialContext());
args.setCptId(CredentialConstant.AUTHORIZATION_CPT);
String privateKey = weIdAuthentication.getWeIdPrivateKey().getPrivateKey();
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(new BigInteger(privateKey));
String keyWeId = WeIdUtils
.convertAddressToWeId(new Address(Keys.getAddress(keyPair)).toString());
args.setIssuer(keyWeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public ResponseData<Credential> addSignature(
result.setExpirationDate(newExpirationDate);
}
String privateKey = weIdPrivateKey.getPrivateKey();
ECKeyPair keyPair = ECKeyPair.create(new BigInteger(privateKey));
ECKeyPair keyPair = DataToolUtils.createKeyPairFromPrivate(new BigInteger(privateKey));
String keyWeId = WeIdUtils
.convertAddressToWeId(new Address(Keys.getAddress(keyPair)).toString());
if (!weIdService.isWeIdExist(keyWeId).getResult()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ public ResponseData<List<Integer>> getAllClaimPolicies(Integer startPos, Integer
if (startPos < 0 || num < 1) {
return new ResponseData<>(null, ErrorCode.ILLEGAL_INPUT);
}
return cptServiceEngine.getCptLists(startPos, num, WeIdConstant.POLICY_DATA_INDEX);
return cptServiceEngine.getCptIdList(startPos, num, WeIdConstant.POLICY_DATA_INDEX);
}

@Override
public ResponseData<Integer> getPolicyCount() {
return cptServiceEngine.getCptCount(WeIdConstant.POLICY_DATA_INDEX);
}
}
Loading

0 comments on commit 012c95a

Please sign in to comment.