diff --git a/SignSdk/src/main/java/com/onlychain/signsdk/bean/BaseActionBean.java b/SignSdk/src/main/java/com/onlychain/signsdk/bean/BaseActionBean.java index 601cd53..1ec2995 100644 --- a/SignSdk/src/main/java/com/onlychain/signsdk/bean/BaseActionBean.java +++ b/SignSdk/src/main/java/com/onlychain/signsdk/bean/BaseActionBean.java @@ -33,12 +33,12 @@ public boolean checkSig(byte[] publicKeyBin){ * @param sigStr * @return */ - public boolean checkApiSign(byte[] publicKeyBin,String message,String sigStr){ + /*public boolean checkApiSign(byte[] publicKeyBin,String message,String sigStr){ if (Secp256k1.verify(PublicKey.parse(publicKeyBin), Hash.sha256(Hash.sha256(message.getBytes())), Signature.parse(OcMath.hexStringToByteArray(sigStr)))) return true; else return false; - } + }*/ public boolean checkSign(byte[] publicKeyBin,String message,String sigStr){ if (Secp256k1.verify(PublicKey.parse(publicKeyBin), Hash.sha256(Hash.sha256(OcMath.hexStringToByteArray(message))), Signature.parse(OcMath.hexStringToByteArray(sigStr)))) @@ -55,7 +55,7 @@ public boolean checkSign(byte[] publicKeyBin,String message,String sigStr){ * @return */ public String makeSign(byte[] privateKeyBin,String message){ - return OcMath.toHexStringNoPrefix(Secp256k1.sign(privateKeyBin,Hash.sha256(Hash.sha256((message).getBytes()))).serialize()); + return OcMath.toHexStringNoPrefix(Secp256k1.sign(privateKeyBin,Hash.sha256(Hash.sha256(OcMath.hexStringToByteArray(message)))).serialize()); } public String getCommitData() { diff --git a/app/src/main/java/com/onlychain/ocsignsdk/ApiSignTools.java b/app/src/main/java/com/onlychain/ocsignsdk/ApiSignTools.java index fdd4290..cdbd005 100644 --- a/app/src/main/java/com/onlychain/ocsignsdk/ApiSignTools.java +++ b/app/src/main/java/com/onlychain/ocsignsdk/ApiSignTools.java @@ -26,6 +26,6 @@ public static void main(String[] args) { //服务端:提取json中公钥、整json内容以及header中的sign对其验签 - System.out.println(mBaseActionBean.checkApiSign(mAccountBean.getPublicKeyBin(),jsonMsg,"30450221008fe7f0f7bb55da842522ba91565065eae37c0bf3b06b402b129c34b288d8084402202247716b7cb03545eb455ef36c7c4070db905250615a9a4b975d49f5dadc2441")); +// System.out.println(mBaseActionBean.checkApiSign(mAccountBean.getPublicKeyBin(),jsonMsg,"30450221008fe7f0f7bb55da842522ba91565065eae37c0bf3b06b402b129c34b288d8084402202247716b7cb03545eb455ef36c7c4070db905250615a9a4b975d49f5dadc2441")); } }