makeShareByFile
In two-party operations, this function is called to split the original data of node 0 (compute party) and node 1 (non-compute party) into shares. When node 0 calls this function, it sets isRecvShare to 1 to receive the shares sent by node 1, and then sets isRecvShare to 0 to split its own data into shares. When the non-compute party calls this function, it sets isRecvShare to 0 to split its own data into shares and then sends the shares to the compute party. In three-party operations, this function is called to split the original data of any two nodes among node 0 (compute party) and nodes 1 and 2 (non-compute parties) into shares. Assume that nodes 0 and 1 have data. When node 0 calls this function, it sets isRecvShare to 1 to receive the shares sent by node 1, and then sets isRecvShare to 0 to split its own data into shares. When node 1 calls this function, it sets isRecvShare to 0 to split its own data into shares and sends the shares to node 0, and sets isRecvShare to 1 to receive the shares sent by node 0. Then, node 2 sets isRecvShare to 1 to receive the shares sent by node 0 and sets isRecvShare to 1 to receive the shares sent by node 1.
int makeShareByFile(
DG_TeeCtx *dgTeeCtx,
int isRecvShare,
const DG_MpcFileInput *input,
DG_MpcFileOutput *output
)
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
dgTeeCtx |
KCAL context |
Context initialized in section initTeeCtx. |
Input |
isRecvShare |
|
0 or 1. |
Input |
input |
DG_MpcFileInput |
The value is not null. |
Input |
output |
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 4516 |
4501 DG_ERR_MPC_TEE_TMP_PATH_SET_ERROR |
Invalid parameter Incorrect temporary directory settings |
- |
DG_ERR_MPC_TEE_INVALID_ALGORITHM_TYPE 4514 |
4502 DG_ERR_MPC_TEE_CHUNK_SIZE_SET_ERROR |
Invalid algorithm type Incorrect file chunk size |
- |
Dependency
- dgTeeCtx depends on the successful initialization of initTeeCtx.
- The dependent header file is data_guard_mpc.h.
Example
- Call the makeShareByFile API using the aritOpts output of the successful DG_InitArithmeticOpts call.
- If either node (compute node 0 or 1) returns an error code when calling an API, the node needs to use a task scheduling mechanism to notify the other node to terminate the service process. For example, if compute node 1 returns an error code when calling the makeShareByFile API and compute node 0 is waiting to receive shares, compute node 1 needs to notify compute node 0 to stop receiving.
#include "data_guard_mpc.h" // Compute party 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 *>(shareFilePath.c_str()); teeFileOutput.pathLen = static_cast<uint32_t>(shareFilePath.length()); int ret = opts_->makeShareByFile(dgTeeCtx_, isRecvShare, &teeFileInput, &teeFileOutput);
Parent topic: Arithmetic Operators