记得上下班打卡 | git大法好,push需谨慎

Commit de9e3b8d authored by anjiabin's avatar anjiabin

调试加密解密相关接口

parent c06121f1
package com.liquidnet.common.third.zxlnft.config; package com.liquidnet.common.third.zxlnft.config;
import com.liquidnet.commons.lang.util.BASE64Util;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.io.UnsupportedEncodingException;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -20,6 +23,10 @@ public class ZxlnftConfig { ...@@ -20,6 +23,10 @@ public class ZxlnftConfig {
private String appKey; private String appKey;
@Value("${liquidnet.zxlnft.nftPlatformAddress:ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4}") @Value("${liquidnet.zxlnft.nftPlatformAddress:ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4}")
private String nftPlatformAddress; private String nftPlatformAddress;
@Value("${liquidnet.zxlnft.nftPlatformPubKey:LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb0VjejFVQmdpMERRZ0FFbFNTQk00MHJIZlJFa0NjWUxlRm1RZzE0SHlIcAp5Rk9uSktzblFqbDBCL2JXOStFWnZPblArNW0vMEdkUCtXM29yeG5Kd3p5OHNoYS9OYkQ4QVBmNXlBPT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==}")
private String nftPlatformPubKey;
@Value("${liquidnet.zxlnft.nftPlatformPriKey:LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR1RBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUJITTlWQVlJdEJIa3dkd0lCQVFRZ1VhbTVWM2V6ZFZJTmNoZ28KVDRKL28zMHArMGJCd3hQWUZFL01FdEU3MTZhZ0NnWUlLb0VjejFVQmdpMmhSQU5DQUFTVkpJRXpqU3NkOUVTUQpKeGd0NFdaQ0RYZ2ZJZW5JVTZja3F5ZENPWFFIOXRiMzRSbTg2Yy83bWIvUVowLzViZWl2R2NuRFBMeXlGcjgxCnNQd0E5L25JCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K}")
private String nftPlatformPriKey;
@Value("${liquidnet.zxlnft.walletSdkUrl:'http://127.0.0.1:30505'}") @Value("${liquidnet.zxlnft.walletSdkUrl:'http://127.0.0.1:30505'}")
private String walletSdkUrl; private String walletSdkUrl;
@Value("${liquidnet.zxlnft.nftApiUrl:'https://nfttest2.zxinchain.com'}") @Value("${liquidnet.zxlnft.nftApiUrl:'https://nfttest2.zxinchain.com'}")
...@@ -37,6 +44,26 @@ public class ZxlnftConfig { ...@@ -37,6 +44,26 @@ public class ZxlnftConfig {
return nftPlatformAddress; return nftPlatformAddress;
} }
public String getNftPlatformPubKey(){
String pubKey = null;
try {
pubKey = BASE64Util.decode(nftPlatformPubKey);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return pubKey;
}
public String getNftPlatformPriKey(){
String priKey = null;
try {
priKey = BASE64Util.decode(nftPlatformPriKey);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return priKey;
}
public String getWalletSdkUrl(){ public String getWalletSdkUrl(){
return walletSdkUrl; return walletSdkUrl;
} }
......
...@@ -20,7 +20,7 @@ public class ZxlnftConstant { ...@@ -20,7 +20,7 @@ public class ZxlnftConstant {
public static String WALLET_SDK_07_PRI_KEY_2_PUB_KEY= "/PriKey2PubKey"; public static String WALLET_SDK_07_PRI_KEY_2_PUB_KEY= "/PriKey2PubKey";
public static String WALLET_SDK_08_PUB_KEY_2_ADDRESS = "/PubKey2Address"; public static String WALLET_SDK_08_PUB_KEY_2_ADDRESS = "/PubKey2Address";
public static String WALLET_SDK_09_PRI_KEY_2_ADDRESS = "/PriKey2Address"; public static String WALLET_SDK_09_PRI_KEY_2_ADDRESS = "/PriKey2Address";
public static String WALLET_SDK_10_VERIFY_BY_PUB_KEY = "/verifyByPubKey"; public static String WALLET_SDK_10_VERIFY_BY_PUB_KEY = "/VerifyByPubKey";
public static String WALLET_SDK_11_SM3_HASH = "/SM3Hash"; public static String WALLET_SDK_11_SM3_HASH = "/SM3Hash";
public static String WALLET_SDK_12_SM3_HASH_ENCODE = "/SM3HashEncode"; public static String WALLET_SDK_12_SM3_HASH_ENCODE = "/SM3HashEncode";
......
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,7 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,7 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:20 * @date 2022/2/18 15:20
*/ */
@Data
public class Nft001RegisterVerifyCodeReq { public class Nft001RegisterVerifyCodeReq {
private String mobile;
} }
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,6 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,6 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:20 * @date 2022/2/18 15:20
*/ */
@Data
public class Nft001RegisterVerifyCodeResp { public class Nft001RegisterVerifyCodeResp {
} }
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,12 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,12 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:20 * @date 2022/2/18 15:20
*/ */
@Data
public class Nft002RegisterPersonReq { public class Nft002RegisterPersonReq {
private String personName;
private String email;
private String mobile;
private String verifyCode;
private String idCard;
private int cardType;
} }
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,10 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,10 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:20 * @date 2022/2/18 15:20
*/ */
@Data
public class Nft002RegisterPersonResp { public class Nft002RegisterPersonResp {
/**
* 用户唯一标识
*/
private String userIdentification;
} }
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,16 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,16 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:22 * @date 2022/2/18 15:22
*/ */
@Data
public class Nft003RegisterPersonPlatformReq { public class Nft003RegisterPersonPlatformReq {
private String personName;
/**
* 用户邮箱(非必填)
*/
private String email;
private String mobile;
private String idCard;
private int cardType;
private String platformPubKey;
private String platformSignData;
} }
package com.liquidnet.common.third.zxlnft.dto.nft; package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +11,10 @@ package com.liquidnet.common.third.zxlnft.dto.nft; ...@@ -9,5 +11,10 @@ package com.liquidnet.common.third.zxlnft.dto.nft;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/18 15:22 * @date 2022/2/18 15:22
*/ */
@Data
public class Nft003RegisterPersonPlatformResp { public class Nft003RegisterPersonPlatformResp {
/**
* 用户唯一标识
*/
private String userIdentification;
} }
package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: Nft054QueryUserAddressBelongToUser
* @Package com.liquidnet.common.third.zxlnft.dto.nft
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 15:01
*/
@Data
public class Nft054QueryUserAddressBelongToUserReq {
/**
* 第一个地址
*/
private String address1;
/**
* 第二个地址
*/
private String address2;
/**
* 平台公钥
*/
private String platformPubKey;
/**
* 平台签名信息:sign(address1+address2)
*/
private String platformSignData;
}
package com.liquidnet.common.third.zxlnft.dto.nft;
import lombok.Data;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: Nft054QueryUserAddressBelongToUser
* @Package com.liquidnet.common.third.zxlnft.dto.nft
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 15:01
*/
@Data
public class Nft054QueryUserAddressBelongToUserResp {
/**
* true 同一主体
* false: 非同一主体
*/
private Boolean result;
}
...@@ -21,4 +21,13 @@ public class SignByPriKeyReq { ...@@ -21,4 +21,13 @@ public class SignByPriKeyReq {
* 签名后的数据 * 签名后的数据
*/ */
private String data; private String data;
private static final SignByPriKeyReq obj = new SignByPriKeyReq();
public static SignByPriKeyReq getNew() {
try {
return (SignByPriKeyReq) obj.clone();
} catch (CloneNotSupportedException e) {
return new SignByPriKeyReq();
}
}
} }
...@@ -21,4 +21,13 @@ public class SignByPriKeyResp { ...@@ -21,4 +21,13 @@ public class SignByPriKeyResp {
* 签名后的数据 * 签名后的数据
*/ */
private String signedData; private String signedData;
private static final SignByPriKeyResp obj = new SignByPriKeyResp();
public static SignByPriKeyResp getNew() {
try {
return (SignByPriKeyResp) obj.clone();
} catch (CloneNotSupportedException e) {
return new SignByPriKeyResp();
}
}
} }
...@@ -25,4 +25,14 @@ public class VerifyByPubKeyReq { ...@@ -25,4 +25,14 @@ public class VerifyByPubKeyReq {
* 签名前的数据 * 签名前的数据
*/ */
private String data; private String data;
private static final VerifyByPubKeyReq obj = new VerifyByPubKeyReq();
public static VerifyByPubKeyReq getNew() {
try {
return (VerifyByPubKeyReq) obj.clone();
} catch (CloneNotSupportedException e) {
return new VerifyByPubKeyReq();
}
}
} }
...@@ -15,4 +15,5 @@ import lombok.Data; ...@@ -15,4 +15,5 @@ import lombok.Data;
public class VerifyByPubKeyResp { public class VerifyByPubKeyResp {
private String err; private String err;
private Boolean isValid; private Boolean isValid;
} }
...@@ -4,84 +4,84 @@ import com.liquidnet.common.third.zxlnft.dto.wallet.*; ...@@ -4,84 +4,84 @@ import com.liquidnet.common.third.zxlnft.dto.wallet.*;
public interface WalletSdkService { public interface WalletSdkService {
/** /**
* 生成助记词 * 1.生成助记词
* @param req * @param req
* @return * @return
*/ */
CreateMnemonicResp createMnemonic(CreateMnemonicReq req); CreateMnemonicResp createMnemonic(CreateMnemonicReq req);
/** /**
* Api签名 * 2.Api签名
* @param req * @param req
* @return * @return
*/ */
GenerateApiSignResp generateApiSign(GenerateApiSignReq req); GenerateApiSignResp generateApiSign(GenerateApiSignReq req);
/** /**
* 文件上传至cos * 3.文件上传至cos
* @param req * @param req
* @return * @return
*/ */
UploadToCosResp uploadToCos(UploadToCosReq req); UploadToCosResp uploadToCos(UploadToCosReq req);
/** /**
* 文件上传至cos(form-data文件提交) * 4.文件上传至cos(form-data文件提交)
* @param req * @param req
* @return * @return
*/ */
UploadFileToCosResp uploadFileToCos(UploadFileToCosReq req); UploadFileToCosResp uploadFileToCos(UploadFileToCosReq req);
/** /**
* 派生生成子公司钥对 * 5.派生生成子公司钥对
* @param req * @param req
* @return * @return
*/ */
DeriveKeyPairResp deriveKeyPair(DeriveKeyPairReq req); DeriveKeyPairResp deriveKeyPair(DeriveKeyPairReq req);
/** /**
* sdk-签名 * 6.sdk-签名
* @param req * @param req
* @return * @return
*/ */
SignByPriKeyResp signByPriKey(SignByPriKeyReq req); SignByPriKeyResp signByPriKey(SignByPriKeyReq req);
/** /**
* sdk-私钥生成对应公钥 * 7.sdk-私钥生成对应公钥
* @param req * @param req
* @return * @return
*/ */
PriKey2PubKeyResp priKey2PubKey(PriKey2PubKeyReq req); PriKey2PubKeyResp priKey2PubKey(PriKey2PubKeyReq req);
/** /**
* sdk-公钥生成对应地址 * 8.sdk-公钥生成对应地址
* @param req * @param req
* @return * @return
*/ */
PubKey2AddressResp pubKey2Address(PubKey2AddressReq req); PubKey2AddressResp pubKey2Address(PubKey2AddressReq req);
/** /**
* sdk-私钥生成对应地址 * 9.sdk-私钥生成对应地址
* @param req * @param req
* @return * @return
*/ */
PriKey2AddressResp priKey2Address(PriKey2AddressReq req); PriKey2AddressResp priKey2Address(PriKey2AddressReq req);
/** /**
* sdk-签名 * 10.sdk-签名
* @param req * @param req
* @return * @return
*/ */
VerifyByPubKeyResp verifyByPubKey(VerifyByPubKeyReq req); VerifyByPubKeyResp verifyByPubKey(VerifyByPubKeyReq req);
/** /**
* sdk-SM3哈希 * 11.sdk-SM3哈希
* @param req * @param req
* @return * @return
*/ */
SM3HashResp sM3Hash(SM3HashReq req); SM3HashResp sM3Hash(SM3HashReq req);
/** /**
* sdk-SM3哈希EnCode * 12.sdk-SM3哈希EnCode
* @param req * @param req
* @return * @return
*/ */
......
...@@ -98,7 +98,29 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -98,7 +98,29 @@ public class WalletSdkServiceImpl implements WalletSdkService {
@Override @Override
public SignByPriKeyResp signByPriKey(SignByPriKeyReq req) { public SignByPriKeyResp signByPriKey(SignByPriKeyReq req) {
return null; JSONObject json = new JSONObject();
json.put("priKey", req.getPriKey());
json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_06_SIGN_BY_PRI_KEY;
log.info("signByPriKey--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null;
// ObjectNode objectNode = JsonUtils.OM().createObjectNode();
try {
response = HttpUtil.postJson(requestUrl,json.toString(),commonHeader);
} catch(HttpClientErrorException e) {
log.error("signByPriKey error", e);
}catch (Exception e) {
log.error("signByPriKey error",e);
}
log.info("signByPriKey--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
SignByPriKeyResp resp = JsonUtils.fromJson(response,SignByPriKeyResp.class);
return resp;
} }
@Override @Override
...@@ -118,7 +140,29 @@ public class WalletSdkServiceImpl implements WalletSdkService { ...@@ -118,7 +140,29 @@ public class WalletSdkServiceImpl implements WalletSdkService {
@Override @Override
public VerifyByPubKeyResp verifyByPubKey(VerifyByPubKeyReq req) { public VerifyByPubKeyResp verifyByPubKey(VerifyByPubKeyReq req) {
return null; JSONObject json = new JSONObject();
json.put("pubKey", req.getPubKey());
json.put("signedData", req.getSignedData());
json.put("data", req.getData());
String requestUrl = zxlnftConfig.getWalletSdkUrl() + ZxlnftConstant.WALLET_SDK_10_VERIFY_BY_PUB_KEY;
log.info("verifyByPubKey--->>> request url : {} body : {} ",requestUrl, json.toString());
String response = null;
try {
response = HttpUtil.postJson(requestUrl,json.toString(),commonHeader);
} catch(HttpClientErrorException e) {
log.error("verifyByPubKey error", e);
}catch (Exception e) {
log.error("verifyByPubKey error",e);
}
log.info("verifyByPubKey--->>> response : {} ",response);
if (StringUtils.isEmpty(response)) {
return null;
}
VerifyByPubKeyResp resp = JsonUtils.fromJson(response,VerifyByPubKeyResp.class);
return resp;
} }
@Override @Override
......
...@@ -32,6 +32,48 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService ...@@ -32,6 +32,48 @@ public class ZxlnftSdkServiceImpl implements ZxlnftSdkService
private MultiValueMap<String, String> commonHeader = new LinkedMultiValueMap(); private MultiValueMap<String, String> commonHeader = new LinkedMultiValueMap();
// @Override
// public Nft001RegisterVerifyCodeResp nft001RegisterVerifyCode(Nft001RegisterVerifyCodeReq req) {
// zxlnftBiz.buildHeader(commonHeader);
//
// JSONObject json = new JSONObject();
// json.put("mobile", req.get);
// json.put("apKey", req.getAppKey());
//
// String requestUrl = zxlnftConfig.getNftApiUrl() + ZxlnftConstant.ZXL_NFT_016_IDENTITY_BIND_QUERY_URL;
// log.info("nft001RegisterVerifyCode--->>> request url : {} body : {} ",requestUrl, params.toString());
//
// String response = null;
//// ObjectNode objectNode = JsonUtils.OM().createObjectNode();
// try {
// response = HttpUtil.postJson(requestUrl,json.toString(),commonHeader);
// } catch(HttpClientErrorException e) {
// log.error("nft001RegisterVerifyCode error", e);
// }catch (Exception e) {
// log.error("nft001RegisterVerifyCode error",e);
// }
// log.info("nft001RegisterVerifyCode--->>> response : {} ",response);
//
// if (StringUtils.isEmpty(response)) {
// return null;
// }
//
// Nft001RegisterVerifyCodeResp resp = Nft001RegisterVerifyCodeResp.getNew();
// JSONObject json = JSONObject.parseObject(response);
// if (json.containsKey("retCode") && json.containsKey("data") && json.getInteger("retCode").intValue() == 0) {
// JSONObject data = json.getJSONObject("data");
// resp = JsonUtils.fromJson(data.toJSONString(),Nft001RegisterVerifyCodeResp.class);
// }else {
// if (json.containsKey("retCode") && json.getInteger("retCode").intValue() != 0) {
// throw new ZxlNftException(String.valueOf(json.getInteger("retCode")), json.getString("retMsg") + ", address:" + req.getAddressList());
// }
// throw new ZxlNftException(json.getString("retCode"), json.getString("retMsg") + ", address:" + req.getAddressList());
// }
//
// log.info("nft001RegisterVerifyCode--->>> return result : {} ",resp.toString());
// return resp;
// }
@Override @Override
public Nft001RegisterVerifyCodeResp nft001RegisterVerifyCode(Nft001RegisterVerifyCodeReq req) { public Nft001RegisterVerifyCodeResp nft001RegisterVerifyCode(Nft001RegisterVerifyCodeReq req) {
return null; return null;
......
...@@ -3,10 +3,7 @@ package com.liquidnet.common.third.zxlnft.util; ...@@ -3,10 +3,7 @@ package com.liquidnet.common.third.zxlnft.util;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig; import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryReq; import com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryReq;
import com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryResp; import com.liquidnet.common.third.zxlnft.dto.nft.Nft016IdentityBindQueryResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq; import com.liquidnet.common.third.zxlnft.dto.wallet.*;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignResp;
import com.liquidnet.common.third.zxlnft.service.WalletSdkService; import com.liquidnet.common.third.zxlnft.service.WalletSdkService;
import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService; import com.liquidnet.common.third.zxlnft.service.ZxlnftSdkService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -33,6 +30,8 @@ public class ZxlnftSdkUtil { ...@@ -33,6 +30,8 @@ public class ZxlnftSdkUtil {
@Autowired @Autowired
private ZxlnftSdkService zxlnftSdkService; private ZxlnftSdkService zxlnftSdkService;
public CreateMnemonicResp createMnemonic(CreateMnemonicReq req){ public CreateMnemonicResp createMnemonic(CreateMnemonicReq req){
CreateMnemonicResp resp = walletSdkService.createMnemonic(req); CreateMnemonicResp resp = walletSdkService.createMnemonic(req);
return resp; return resp;
...@@ -43,6 +42,17 @@ public class ZxlnftSdkUtil { ...@@ -43,6 +42,17 @@ public class ZxlnftSdkUtil {
return resp; return resp;
} }
public SignByPriKeyResp signByPriKey(SignByPriKeyReq req){
SignByPriKeyResp resp = walletSdkService.signByPriKey(req);
return resp;
}
public VerifyByPubKeyResp verifyByPubKey(VerifyByPubKeyReq req){
VerifyByPubKeyResp resp = walletSdkService.verifyByPubKey(req);
return resp;
}
public Nft016IdentityBindQueryResp nft016IdentityBindQuery(Nft016IdentityBindQueryReq req){ public Nft016IdentityBindQueryResp nft016IdentityBindQuery(Nft016IdentityBindQueryReq req){
req.setAddressList(zxlnftConfig.getNftPlatformAddress()); req.setAddressList(zxlnftConfig.getNftPlatformAddress());
Nft016IdentityBindQueryResp resp = zxlnftSdkService.nft016IdentityBindQuery(req); Nft016IdentityBindQueryResp resp = zxlnftSdkService.nft016IdentityBindQuery(req);
......
package com.liquidnet.service.zxlnft.test; package com.liquidnet.service.zxlnft.test;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq; import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignReq; import com.liquidnet.common.third.zxlnft.dto.wallet.GenerateApiSignReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.SignByPriKeyReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.VerifyByPubKeyReq;
import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil; import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
...@@ -22,10 +25,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -22,10 +25,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Slf4j @Slf4j
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest @SpringBootTest
public class TestZxlnftSdkUtil { public class TestZxlWalletSdkUtil {
@Autowired @Autowired
private ZxlnftSdkUtil zxlnftSdkUtil; private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlnftConfig zxlnftConfig;
@Test @Test
public void createMnemonic(){ public void createMnemonic(){
CreateMnemonicReq req = CreateMnemonicReq.getNew(); CreateMnemonicReq req = CreateMnemonicReq.getNew();
...@@ -39,4 +45,24 @@ public class TestZxlnftSdkUtil { ...@@ -39,4 +45,24 @@ public class TestZxlnftSdkUtil {
req.setAppKey(""); req.setAppKey("");
zxlnftSdkUtil.generateApiSign(req); zxlnftSdkUtil.generateApiSign(req);
} }
@Test
public void signByPriKey(){
SignByPriKeyReq req = SignByPriKeyReq.getNew();
// req.setPriKey(zxlnftConfig.getNftPlatformPriKey());
req.setPriKey(zxlnftConfig.getNftPlatformPriKey());
req.setData("ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4");
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxlnftSdkUtil.signByPriKey(req);
}
@Test
public void verifyByPubKey(){
VerifyByPubKeyReq req = VerifyByPubKeyReq.getNew();
req.setPubKey(zxlnftConfig.getNftPlatformPubKey());
req.setData("ZXa66c8a684727d0f9aaa434044362aa8a18b61bb4-");
req.setSignedData("3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54");
//3045022072ba19d02f43ae883764ffa43d111ab62fd0bcd6ace31bc91356e7ce38756cbb022100deb5f7666f4768f297ccdf386a867d2a0d71227548f2595a62130e5016fb1d54
zxlnftSdkUtil.verifyByPubKey(req);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment