Rate This Document
Findability
Accuracy
Completeness
Readability

clientCalculate

The client sends a query key to the server to obtain a query result.

int clientCalculate(
    DG_TeeCtx *dgTeeCtx,
    DG_TeeMode outputMode,
    DG_TeeInput *input,
    DG_TeeOutput **output
)

Parameters

Parameter

Description

Value Range

Input/Output

dgTeeCtx

MPC context

Context initialized in section DG_InitPsmOpts.

Input

outputMode

Result form

TEE_OUTPUT_STRING and TEE_OUTPUT_INDEX.

Input

input

Value to be queried

DG_TeeInput

String arrays are supported.

Input

output

Query result

DG_TeeOutput

String arrays and input array indices are supported.

Output

enum DG_TeeMode {
    TEE_OUTPUT_STRING,
    TEE_OUTPUT_INDEX
};
Table 1 DG_TeeInput structure

Name

Type

Description

data

DG_MpcDataUnion

The types of the input data strings, doubleNumbers, and u64Numbers are respectively DG_String *, double *, and u64 *.

size

uint64_t

Data volume

dataType

DG_MpcDataType

The enumerated data types are as follows:

MPC_STRING (PSM query)

MPC_INT (indices of PSM intersecting strings)

Table 2 DG_MpcDataUnion

Name

Type

Description

strings

DG_String

String array

u64Numbers

u64

u64 array

doubleNumbers

double

Double array

Return Values

  • Success: 0 is returned.
  • Failure: The error code is returned.

Error Codes

Error Code

Value

Description

Remarks

DG_SUCCESS

0

Success

None.

DG_FAILURE

1

Communication failure

Failed to send and receive network requests.

DG_ERR_MALLOC_FAIL

51

Memory allocation failure

None.

DG_ERR_STRCPY_FAIL

54

String copy failure

None.

DG_ERR_MPC_TEE_INVALID_NODE_INFO

4503

Invalid TEE node information

None.

DG_ERR_MPC_TEE_INVALID_PARAM

4501

Parameter verification failure

dgCfg is null or the dgTeeCtx double pointer is null.

Dependency

  • dgCfg depends on the MPC configuration in section DataGuard APIs for Configuring an Operation Set, and the configured dgCfg is used as the input parameter of this API.
    • psmOpts depends on the successful initialization in section DG_InitPsmOpts of the function group for the PSM operator.
  • #include "data_guard_mpc.h": required header file

Example

#include  "data_guard_mpc.h"
void BuildDgString(std::vector<std::string> &strings, DG_String **dg, unsigned int &size)
{
    size = strings.size();
    DG_String *dgString = new DG_String[strings.size()];
    for (size_t i = 0; i < strings.size(); i++) {
        dgString[i].str = strdup(strings[i].c_str());
        dgString[i].size = strings[i].size() + 1;
    }
    *dg = dgString;
}
DG_TeeInput BuildTeeInput(std::vector<std::string> inputData)
{
    DG_String *dgInput;
    unsigned int size;
    BuildDgString(inputData, &dgInput, size);
    DG_TeeInput dgTeeInput = {};
    dgTeeInput.dataType = MPC_STRING;
    dgTeeInput.data.strings = dgInput;
    dgTeeInput.size = size;
    return dgTeeInput;
}
DG_TeeInput teeInput = BuildTeeInput("name", "age", "a", "hello");
DG_TeeOutput *output = nullptr;
// psmOpts is the result of the successful DG_InitPsmOpts call, and dgTee is the result of the successful initTeeMpcSql call.
int rv = psmOpts.clientCalculate(nodeCtx, TEE_OUTPUT_STRING, &teeInput, &output);
if (rv != 0) {
    return rv;
}

Call the initTeeCtx API using the psmOpts output of the successful DG_InitPsmOpts call.