Release 4.0 has implemented the shielded TRC-20 contract, which can hide the source address, destination address, and the token amount for TRC-20 transaction and provide users better privacy. The shielded TRC-20 contract has three core functions: mint
, transfer
and burn
. mint
is used to transform the public TRC-20 token to shielded token; transfer
is used for shielded token transactions; burn
is used to transform the shielded token back to the public TRC-20 token. To support the shielded TRC-20 contract, four new zero-knowledge instructions (verifyMintProof
, verifyTransferProof
, verifyBurnProof
and pedersenHash
) are add in TVM, which make it convenient to provide privacy for arbitrary TRC-20 contract.
New features:
-
add 4 new instructions (
verifyMintProof
,verifyTransferProof
,verifyBurnProof
andpedersenHash
) in TVM to support TRC20 shielded transactions based on zk-SNARKS.
verifyMintProof
: used to validate the zero-knowledge proof formint
function.
verifyTransferProof
: used to validate the zero-knowledge proof fortransfer
function.
verifyBurnProof
: used to validate the zero-knowledge proof forburn
function.
pedersenHash
: used to compute the Pedersen hash function. -
update the initial parameters of zk-SNARK scheme generated by the MPC torch (#3210).
-
add the APIs to support shielded TRC-20 contract transaction (#3172).
1. Create shielded contract parameters
rpc CreateShieldedContractParameters (PrivateShieldedTRC20Parameters) returns (ShieldedTRC20Parameters) {}
2. Create shielded contract parameters without ask
rpc CreateShieldedContractParametersWithoutAsk (PrivateShieldedTRC20ParametersWithoutAsk) returns (ShieldedTRC20Parameters) {}
3. Scan shielded TRC20 notes by ivk
rpc ScanShieldedTRC20NotesbyIvk (IvkDecryptTRC20Parameters) returns (DecryptNotesTRC20) {}
4. Scan shielded TRC20 notes by ovk
rpc ScanShieldedTRC20NotesbyOvk (OvkDecryptTRC20Parameters) returns (DecryptNotesTRC20) {}
5. Get the is_spent status of shielded TRC20 note
rpc IsShieldedTRC20ContractNoteSpent (NfTRC20Parameters) returns (NullifierResult) {}
6. Get the trigger input for the shielded TRC20
rpc GetTriggerInputForShieldedTRC20Contract (ShieldedTRC20TriggerContractParameters) returns (BytesMessage) {}
-
support the
ovk
to scan the transparent output ofburn
transaction (#3203). -
support the
burn
transaction with zero or one shielded output (#3224). -
add data field in transaction log trigger class for future memo note (#3200).
The following TIPs are implemented in this release:
- TIP-135: allows deploying the shielded TRC-20 contract, guarantee the privacy of shielded contract transactioin.
- TIP-137: implements three zero-knowledge proof instructions in TVM to support the shielded TRC-20 contract (#3172).
- TIP-138: implements the Pedersen hash computation instruction in TVM to support the shielded TRC-20 contract (#3172).
Fixed bugs:
- Check if null before getInstance when get transaction info from DB to fix exception of
getTransactioninfoByBlkNum
(#3165).