All Products
Search
Document Center

Blockchain as a Service:Privacy Interface

Last Updated:May 22, 2019

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:

  1. function test_verify_commitment() public returns (bool)
  2. {
  3. bytes memory b2 = new bytes(65);
  4. string memory name = "abcdefghijklmnopqrstuvwxyz";
  5. b2 = "0123456789012345678901234567890123456789012345678901234567890123";
  6. identity addr = 0x123456;
  7. return verify_commitment(name, 0x30, addr, b2);
  8. }
  9. function test_verify_balance() public returns (bool)
  10. {
  11. return verify_balance(0x21);
  12. }
  13. function test_verify_range() public returns (bool)
  14. {
  15. return verify_range(0x10, 0x20);
  16. }

VerifyCommitment

You can call the VerifyCommitment function to verify a commitment.

Function

  1. 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

  1. 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

  1. 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.