隐私接口函数示例
蚂蚁区块链平台在支持原生 Solidity 的接口基础上,又添加了部分隐私接口函数,主要包括三个函数:
- VerifyCommitment
- VerifyRange
- VerifyBalance
其使用示例如下所示:
function test_verify_commitment() public returns (bool)
{
bytes memory b2 = new bytes(65);
string memory name = "abcdefghijklmnopqrstuvwxyz";
b2 = "0123456789012345678901234567890123456789012345678901234567890123";
identity addr = 0x123456;
return verify_commitment(name, 0x30, addr, b2);
}
function test_verify_balance() public returns (bool)
{
return verify_balance(0x21);
}
function test_verify_range() public returns (bool)
{
return verify_range(0x10, 0x20);
}
VerifyCommitment
VerifyCommitment 为承诺验证函数。
函数原型
VerifyCommitment(string name, uint index, identity to,const bytes value_enc) returns(bool result);
请求参数
参数 |
必选 |
类型 |
说明 |
name |
是 |
string |
承诺类型,0 表示 input,1 表示 output |
index |
是 |
uint |
承诺索引 |
to |
是 |
identity |
承诺所属账户 |
value_enc |
是 |
bytes |
承诺数值 |
返回值
参数 |
必选 |
类型 |
说明 |
result |
是 |
bool |
方法返回值,成功为 true,否则为 false |
VerifyBalance
balance 校验函数。
函数原型
VerifyBalance(uint range) returns(bool);
请求参数
参数 |
必选 |
类型 |
说明 |
index |
是 |
uint |
balance 验证索引 |
返回值
参数 |
必选 |
类型 |
说明 |
result |
是 |
bool |
方法返回值,成功为 true,否则为 false |
VerifyRange
VerifyRange 是验证范围函数。
函数原型
VerifyRange(uint index, int min_value) returns(bool);
请求参数
参数 |
必选 |
类型 |
说明 |
index |
是 |
uint32 |
验证索引范围 |
min_value |
是 |
int64 |
验证范围最小值 |
返回值
参数 |
必选 |
类型 |
说明 |
result |
是 |
bool |
方法返回值,成功为 true,否则为 false |