Client

Contract user can send the payload for private execution through the send() function of the client and listen for event from the callback() function on the client contract.

User prepares the params and packed ExecutionInfo struct which client contract will then pass onto gateway contract for preExecution where it does payload hash sginature verrification and then logs out the new task which relayer picks up and sends to the private computational network, and then after the computation is done the relayer packs the logs from private compuation and call back the gateway with logs fro postExecution where the gateway contract after doing payload hash verification , result signature verification, packet signature verification, calls back the callback onclient with the computed result and client logs out the computed result.

Client Interface:

interface IClient {
    
    /// @param _userAddress   User Address
    /// @param _sourceNetwork Source network of msg
    /// @param _routingInfo   Routing info for computation
    /// @param _payloadHash   Payload hash 
    /// @param _info          ExecutionInfo struct
    function send(
        address _userAddress,
        string memory _sourceNetwork,
        string memory _routingInfo,
        bytes32 _payloadHash,
        ExecutionInfo memory _info
    ) external;
    
    /// @param _taskId        Task Id of the computation
    /// @param _result        Privately computed result
    function callback(uint256 _taskId, bytes memory _result) external;
}

Data Structs:

struct ExecutionInfo {
        bytes user_key;
        string routing_code_hash;
        string handle;
        bytes12 nonce;
        bytes payload;
        bytes payload_signature;
}

For sending a transaction for computation you just have to do a send() call on the client like the below given example:

address clientContractAddress = 0xAddress

IClient(clientContractAddress).send(sender, sourceNetwork, routingInfo, payloadHash, ExecutionInfo);

Last updated