forked from FISCO-BCOS/FISCO-BCOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibZkg.sol
78 lines (67 loc) · 1.75 KB
/
LibZkg.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* file LibZkg.sol
* author jimmyshi
* time 2018-03-01
* Print log into eth
*/
pragma solidity ^0.4.2;
import "LibString.sol";
import "LibInt.sol";
library LibZkg {
using LibString for *;
using LibInt for *;
//EthLog的EthCallId定义
function tx1To1CallId() internal constant returns(uint32) {
return 0x5A4B47; //一对一匿名可监管交易验证
}
function to1To1Verify(
string inputRt0, string inputRt1,
string inputSn0, string inputSn1,
string outputCm0, string outputCm1,
uint64 vpubOld,
uint64 vpubNew,
string g,
string gpk,
string gData,
string proof
)
internal constant
returns(uint)
{
/*
* 受到参数个数限制,调用ethcall前要封装
* params 中的内容,每个都是64个char
*/
string memory params = "";
params = params.concat(inputRt0, inputRt1);
params = params.concat(inputSn0, inputSn1);
params = params.concat(outputCm0, outputCm1);
params = params.concat(g, gpk);
return callEvm(
params,
vpubOld, vpubNew,
gData,
proof
);
}
//调用底层的ethcall
function callEvm(
string params,
uint64 vpubOld,
uint64 vpubNew,
string gData,
string proof
)
internal constant
returns(uint)
{
uint32 callId = tx1To1CallId();
uint r;
assembly{
r := ethcall(callId, params,
vpubOld, vpubNew,
gData, proof, 0, 0, 0, 0)
}
return r;
}
}