mirror of
https://gitee.com/BDWare/common
synced 2025-01-10 09:54:13 +00:00
feat: support onCreateParams
This commit is contained in:
parent
2d6c0e4874
commit
4047f03151
@ -39,6 +39,7 @@ public class Contract extends SM2Verifiable implements Serializable {
|
|||||||
private String hash;
|
private String hash;
|
||||||
private boolean stateful = true; // manifest可配置
|
private boolean stateful = true; // manifest可配置
|
||||||
private YjsType yjsType;
|
private YjsType yjsType;
|
||||||
|
private JsonElement createParam;
|
||||||
|
|
||||||
public int getShardingId() {
|
public int getShardingId() {
|
||||||
return this.shardingId;
|
return this.shardingId;
|
||||||
@ -226,4 +227,11 @@ public class Contract extends SM2Verifiable implements Serializable {
|
|||||||
this.buildTime = buildTime;
|
this.buildTime = buildTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCreateParam(JsonElement ele) {
|
||||||
|
createParam = ele;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement getCreateParam() {
|
||||||
|
return createParam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bdware.sc.boundary.utils;
|
package org.bdware.sc.boundary.utils;
|
||||||
|
|
||||||
|
import org.bdware.sc.bean.ContractRequest;
|
||||||
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
|
||||||
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
|
||||||
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||||||
@ -18,7 +19,20 @@ public class SM2UtilTest {
|
|||||||
String keyPairStr =
|
String keyPairStr =
|
||||||
"{\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\",\"privateKey\":\"b7e504cf951792554bf4a9874be37cb1279d38939444388e2046ee9603b4f0c4\"}";
|
"{\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\",\"privateKey\":\"b7e504cf951792554bf4a9874be37cb1279d38939444388e2046ee9603b4f0c4\"}";
|
||||||
SM2KeyPair keyPair = SM2KeyPair.fromJson(keyPairStr);
|
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
|
@Test
|
||||||
public void base64() {
|
public void base64() {
|
||||||
String gstr =
|
String gstr =
|
||||||
|
Loading…
Reference in New Issue
Block a user