calculateByFile
int calculateByFile (
DG_TeeCtx *dgTeeCtx,
DG_AlgorithmsType type,
DG_MpcFileInput *input,
DG_MpcFileOutput *output
)
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
dgTeeCtx |
KCAL context |
Context initialized in section initTeeCtx. |
Input |
type |
Operator enumeration: DG_AlgorithmsType |
Currently, only PSI_UB is supported. |
Input |
input |
DG_MpcFileInput |
The value is not null. |
Input |
output |
The type of the calculation result: DG_MpcFileOutput |
The value is not null. |
Output |
Name |
Type |
Description |
|---|---|---|
filePath |
char* |
File path |
pathLen |
uint32_t |
Path length |
dataSize |
uint64_t |
Data size |
Name |
Type |
Description |
|---|---|---|
filePath |
char* |
File path |
pathLen |
uint32_t |
Path length |
dataSize |
uint64_t |
Data size |
Return Values
- Success: 0 is returned.
- Failure: The error code is returned.
Error Codes
Error Code |
Value |
Description |
Remarks |
|---|---|---|---|
DG_ERR_MPC_TEE_INVALID_PARAM |
4501 |
Invalid parameter |
- |
DG_ERR_MPC_TEE_INVALID_ALGORITHM_TYPE |
4502 |
Invalid algorithm type |
- |
DG_ERR_MALLOC_FAIL |
51 |
Memory allocation failure |
- |
DG_ERR_MPC_TEE_DIV_IS_ZERO |
4512 |
Division-by-zero error |
- |
DG_FAILURE |
1 |
Operator execution failure |
Failed to verify the parameters. Failed to split data into shares. Failed to receive data from the other node. |
Dependency
- dgTeeCtx depends on the successful initialization of initTeeCtx.
- The dependent header file is data_guard_mpc.h.
Example
Call the calculateByFile API using the teeOpts output of the successful DG_InitPsiOpts call.
#include "data_guard_mpc.h"
int PsiUb::Run(const std::string &inputFilePath, const std::string &outputFilePath, int &outputCount)
{
DG_MpcFileInput teeFileInput;
teeFileInput.filePath = const_cast<char *>(inputFilePath.c_str());
teeFileInput.pathLen = static_cast<uint32_t>(inputFilePath.length());
DG_MpcFileOutput teeFileOutput;
teeFileOutput.filePath = const_cast<char *>(outputFilePath.c_str());
teeFileOutput.pathLen = static_cast<uint32_t>(outputFilePath.length());
teeFileOutput.dataSize = 0;
int res = opts_->calculateByFile(dgTeeCtx_, PSI_UB, &teeFileInput, &teeFileOutput);
outputCount = static_cast<int>(teeFileOutput.dataSize);
return res;
}
Running result: res is 0 and output is not null.