Sample functions for privacy protection operations
Apart from the native Solidity operations, Ant Blockchain provides operations for privacy protection. Three functions are used:
- VerifyCommitment
- VerifyRange
- VerifyBalance
The example is as follows:
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
You can call the VerifyCommitment function to verify a commitment.
Function
VerifyCommitment(string name, uint index, identity to,const bytes value_enc) returns(bool result);
Request parameters
Name |
Required |
Type |
Description |
name |
Yes |
string |
The commitment type. 0 refers to the input. 1 refers to the output. |
index |
Yes |
uint |
The commitment index. |
to |
Yes |
identity |
The account of the commitment. |
value_enc |
Yes |
bytes |
The committed value. |
Response parameters
Name |
Required |
Type |
Description |
result |
Yes |
bool |
The return value of the method. A value of true indicates that the method is called. A value of false indicates that the call has failed. |
VerifyBalance
You can call this function to verify the balance.
Function
VerifyBalance(uint range) returns(bool);
Request parameters
Name |
Required |
Type |
Description |
index |
Yes |
uint |
The index for balance verification. |
Response parameters
Name |
Required |
Type |
Description |
result |
Yes |
bool |
The return value of the method. A value of true indicates that the method is called. A value of false indicates that the call has failed. |
VerifyRange
You can call the VerifyRange function to verify the range.
Function
VerifyRange(uint index, int min_value) returns(bool);
Request parameters
Name |
Required |
Type |
Description |
index |
Yes |
uint32 |
The range of the verification index. |
min_value |
Yes |
int64 |
The minimum value of the verification range. |
Response parameters
Name |
Required |
Type |
Description |
result |
Yes |
bool |
The return value of the method. A value of true indicates that the method is called. A value of false indicates that the call has failed. |