agent-backend/contracts/SM2Example/SM2Example.yjs

23 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-09-26 04:49:24 +00:00
@Permission("SM2")
@Description("SM2Util示例合约")
contract SM2Example{
@Description("无需参数")
export function generateKeyPair(arg){
print(Global.version);
var ret = SM2Util.generateKeyPair();
return JSON.stringify(ret);
}
@Description("示例参数:{\"content\":\"hello\",\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\",\"privateKey\":\"b7e504cf951792554bf4a9874be37cb1279d38939444388e2046ee9603b4f0c4\"}")
export function sign(arg){
arg = JSON.parse(arg);
var ret = SM2Util.sign(arg.content,arg);
return JSON.stringify(ret);
}
@Description("示例参数:{\"content\":\"hello\",\"signature\":\"484115b7946e6a290d04e05ebc808a9e43724c267f68124a2b1f8dbd81160725,1d5968643caaa2c3ce9c15ef26197f8df2bd2dd2a2db67cc52b06f5324f049d3\",\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\"}")
export function verify(arg){
arg = JSON.parse(arg);
var ret = SM2Util.verify(arg.content,arg.signature,arg.publicKey);
return JSON.stringify(ret);
}
}