diff --git a/src/main/entry/org/bdware/sc/bean/Contract.java b/src/main/entry/org/bdware/sc/bean/Contract.java index 59314dd..3cbb86e 100644 --- a/src/main/entry/org/bdware/sc/bean/Contract.java +++ b/src/main/entry/org/bdware/sc/bean/Contract.java @@ -39,6 +39,7 @@ public class Contract extends SM2Verifiable implements Serializable { private String hash; private boolean stateful = true; // manifest可配置 private YjsType yjsType; + private JsonElement createParam; public int getShardingId() { return this.shardingId; @@ -226,4 +227,11 @@ public class Contract extends SM2Verifiable implements Serializable { this.buildTime = buildTime; } + public void setCreateParam(JsonElement ele) { + createParam = ele; + } + + public JsonElement getCreateParam() { + return createParam; + } } diff --git a/src/test/java/org/bdware/sc/boundary/utils/SM2UtilTest.java b/src/test/java/org/bdware/sc/boundary/utils/SM2UtilTest.java index d3bc552..c216d72 100644 --- a/src/test/java/org/bdware/sc/boundary/utils/SM2UtilTest.java +++ b/src/test/java/org/bdware/sc/boundary/utils/SM2UtilTest.java @@ -1,5 +1,6 @@ package org.bdware.sc.boundary.utils; +import org.bdware.sc.bean.ContractRequest; import org.bouncycastle.crypto.AsymmetricCipherKeyPair; import org.bouncycastle.crypto.params.ECPrivateKeyParameters; import org.bouncycastle.crypto.params.ECPublicKeyParameters; @@ -18,7 +19,20 @@ public class SM2UtilTest { String keyPairStr = "{\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\",\"privateKey\":\"b7e504cf951792554bf4a9874be37cb1279d38939444388e2046ee9603b4f0c4\"}"; SM2KeyPair keyPair = SM2KeyPair.fromJson(keyPairStr); + @Test + public void verify2(){ + String toVerify = "GeneralContract|plainTextTransmission|{\"ledger\":\"test\",\"data\":\"上链信息为json格式\"}|04398dfde44290595cd098cd2f904b36367c69f9011719d43fb0955f823cf1386764769bc7c0a5649dcb316d552998a5c106afd268d9db8b6482ce527544a7bd15"; + String sign = "30440220137771d7505abde700c89cfa376f67c564dfdec6ffdb08cb08ff70544be6cb6f0220587296439bedf43f4b0bfec2d7030a8250d369e53af623e50a734e3b6cb780cb"; + String pubkey = "04398dfde44290595cd098cd2f904b36367c69f9011719d43fb0955f823cf1386764769bc7c0a5649dcb316d552998a5c106afd268d9db8b6482ce527544a7bd15"; + ContractRequest cr = new ContractRequest(); + cr.setContractID("GeneralContract"); + cr.setAction("plainTextTransmission"); + cr.setArg("{\"ledger\":\"test\",\"data\":\"上链信息为json格式\"}"); + cr.setPublicKey("04398dfde44290595cd098cd2f904b36367c69f9011719d43fb0955f823cf1386764769bc7c0a5649dcb316d552998a5c106afd268d9db8b6482ce527544a7bd15"); + cr.setSignature("30440220137771d7505abde700c89cfa376f67c564dfdec6ffdb08cb08ff70544be6cb6f0220587296439bedf43f4b0bfec2d7030a8250d369e53af623e50a734e3b6cb780cb"); + System.out.println(cr.verifySignature()); + } @Test public void base64() { String gstr =