APIs for Secure Data Computation

Outsourcing Computation

Main features

Homomorphic encryption technology is adopted to encrypt the data to be sent to a third party for outsourced computation. Users receive the encrypted computation result and then decrypt the raw result, and the third party will not have access to the raw data during the entire process.

Applications: cloud computing, anonymous voting systems, ciphertext retrieval, anonymous access, etc.

Steps involved

  1. Generate the public and private key pair (genHEKeyPair)
  2. Encrypt data with the public key (HEEncrypt)
  3. Homomorphic calculation (HECalc)
  4. Decrypt with the private key (HEDecrypt)

Instructions

  • Interface: genHEKeyPair

  • Description: A helper function usually called by the result party who maintains the private key and publishes the public key and other public information

  • Request [POST]

    {
    	"params": {
            "scheme": "ckks",
            ...
        }
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    paramsjsonA parameter used by the homomorphic encryption algorithm and applies to the specific libraryY
    schemestringThe selected schemeN
    ...stringOther parametersN
  • Response

    {
    	"status": 200,
    	"result":{
    		"pub_key": "0xABCD",
    		"priv_key": "0xDEAD"
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pub_keystringPublic key
    priv_keystringPrivate key
    msgstringSuccess or error message
  • Interface: HEEncrypt

  • Description: A helper function used to encrypt data and is called by the data provider

  • Request [POST]

    {
    	"pub_key": "0xABCD",
        "data": "your data",
        "params": {
            ...
        }
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    pub_keystringPublic key, received from the result partyY
    datastringData to be encryptedY
    paramsjsonOther parameters used by the homomorphic encryption algorithmN
  • Response

    {
    	"status": 200,
    	"result":{
    		"ciphertext": "0x178C"
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    ciphertextstringCiphertext
    msgstringSuccess or error message
  • Interface: HECalc

  • Description: Request for homomorphic computation, usually initiated by the result party

  • Request [POST]

    {
    	"pub_key": "0xABCD",
        "data_path": "/path/to/data",
        "formula": "sum()",   
        "params": {
            ...
        }
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    pub_keystringPublic key, received from the result partyY
    data_pathstringPath of the encrypted dataY
    formulastringFormulas such as summation, multiplication, etc.Y
    paramsjsonOther parameters used by the homomorphic encryption algorithmN
  • Response

    {
    	"status": 200,
    	"result":{
    		"ciphertext": "0xDA7A"
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    ciphertextstringCiphertext result
    msgstringSuccess or error message
  • Interface: HEDecrypt

  • Description: A helper function, called by the result party as he keeps the private key

  • Request [POST]

    {
    	"priv_key": "0xDEAD",
        "data": "ciphered result data",
        "params": {
            ...
        }
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    priv_keystringPrivate keyY
    datastringEncrypted result returned by the party that conducts the homomorphic computationY
    paramsjsonOther parameters used by the homomorphic encryption algorithmN
  • Response

    {
    	"status": 200,
    	"result":{
    		"value": 8
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    valuenumberDecrypted result
    msgstringSuccess or error message

Data Cooperation

Joint Match

Privacy match can be applied in multiple data application scenarios, including joint friend discovery, whitelist/blacklist user match, sample alignment for joint computation, etc.

Main features

Joint Match enables data cooperation between two parties: Requester and Provider. The two parties can obtain the intersection of their data but cannot access any other information in the raw data set. This feature is achieved using Private Set Intersection, and supports the Diffie-Hellman (DH) algorithm and the Homomorphic Encryption (HE) algorithm.

Instructions

  • Interface: runPSITask

  • Request [POST]

    {
    	"algo_type": "DH",
    	"requester": {
    	"name": "orgA",
    	"data_path": "/path/to/data",
    	"data_type": "csv",
    	"key_column": "id_col"
    	},
    	"provider": {
    	"name": "orgB",
    	"data_path": "/path/to/data",
    	"data_type": "csv",
    	"key_column": "id_col"
      },
    	"result_recv_type": 1
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    algo_typestringTypes of algorithms used: DH & HEY
    requesterjsonRequester informationY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    key_columnstringColumn to be operatedY
    providerjsonProvider informationY
    result_recv_typeintHow the result is received: 1 - sent to one party, 2 - sent to two partiesY
  • Response

    {
    	"status": 200,
    	"result":{
    		"path": "/path/to/result/file",
    		"type": "csv",
    		"extra": ""
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    msgstringSuccess or error message
  • Interface: getDataProviders

  • Request [GET]

    None

  • Response

    {
    	"status": 200,
    	"result":{
    		"data_providers": ["orgA", "orgB", "orgC"]
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    data_providerslistOrganization name of all data providers
    msgstringSuccess or error message
  • Interface: getDataPath

  • Request [GET]

    ParameterTypeDescriptionIf required
    data_providerstringOrganization name of the data providerY
  • Response

    {
    	"status": 200,
    	"result":{
    		"data_path": ["/path/to/data1", "/path/to/data2", "/path/to/data3"]
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    data_pathstringData path
    msgstringSuccess or error message
  • Interface: getMetaData

  • Request [GET]

    ParameterTypeDescriptionIf required
    data_providerstringOrganization name of the data providerY
    data_pathstringData pathY
  • Response

    {
    	"status": 200,
    	"result":{
    	"data_type": "csv",
    	"rows_num": 10,
    	"columns_num": 5,
    	"columns_name": ["col1", "col2"]
    },
    "msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    data_typestringData type
    rows_numintNumber of rows of the datasheet
    columns_numintNumber of columns of the datasheet
    columns_namelistName of columns of the datasheet
    msgstringSuccess or error message

Privacy Label Query

The intersection of data between two parties can be matched, and the corresponding Label data can be queried and matched.

Main features

Privacy Label Query allows the Requester to obtain the intersection of data between himself and the Provider, as well as the Label data that corresponds to the intersection, while making sure that the Requester does not disclose the query content and the Provider does not disclose any other data. The function is achieved through Labeled Private Set Intersection, and supports the Diffie-Hellman (DH) algorithm and the Homomorphic Encryption (HE) algorithm.

Instructions

  • Interface: runLabeledPSITask

  • Request [POST]

    {
    	"algo_type": "DH",
    	"requester": {
    	"name": "orgA",
    	"data_path": "/path/to/data",
    	"data_type": "csv",
    	"key_column": "id_col"
    	},
    	"provider": {
    	"name": "orgB",
    	"data_path": "/path/to/data",
    	"data_type": "csv",
    	"key_column": "id_col",
    	"selected_columns": ["col1", "col2"]
      }
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    algo_typestringTypes of algorithms used: DH & HEY
    requesterjsonRequester informationY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    key_columnstringColumn to be operatedY
    providerjsonProvider informationY
    selected_columnslistColumn name of labels to be queriedY
  • Response

    {
    	"status": 200,
    	"result":{
    		"path": "/path/to/result/file",
    		"type": "csv",
    		"extra": ""
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    msgstringSuccess or error message

Joint Query

Main features

Joint Query allows the Requester to obtain the correct query result using the SQL SELECT statement, while making sure that the Request does not disclose the query content and the Provider does not disclose any data in the database other than the query result. The feature supports MPC-based privacy queries and HE-based privacy queries.

Instructions

  • Interface: runPrivacySQLTask

  • Request [POST]

    {
    	"algo_type": "MPC",
    	"requester": {
    	"name": "orgA",
    	"data_path": "/path/to/data",
    	"data_type": "csv"
    	},
    	"provider": {
    	"name": "orgB",
    	"data_path": "/path/to/data",
    	"data_type": "csv"
      },
    	"sql": "select sum(col1) from orgB;"
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    algo_typestringTypes of algorithms used: MPC & HEY
    requesterjsonRequester informationY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    sqlstringSQL statementY
    providerjsonProvider informationY
  • Response

    {
    	"status": 200,
    	"result":{
    		"path": "/path/to/result/file",
    		"type": "csv",
    		"extra": ""
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    msgstringSuccess or error message

Joint Statistical Analysis

A scenario of data collaboration among multi-parties. The feature adopts the privacy-preserving AI framework Rosetta and supports arithmetic operations among three (or more) parties

Main features

Joint Statistical Analysis achieves joint statistical analysis for the data from data providers while making sure that no data provider discloses his sensitive data. The feature provides two methods: common statistical formulas (sum, average, variance, accredited investor discovery, etc.) and custom statistical formulas.

Instructions

  • Interface: runJointStatisticalAnalysisTask

  • Request [POST]

    {
    	"data_providers": [
    		{
    			"name": "orgA",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
    			"key_column": "id_col",
              "data_alias": "df1"
    		},
    		{
    			"name": "orgB",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
    			"key_column": "id_col",
              "data_alias": "df2"
    		}
    	],
    	"result_receivers": ["orgA", "orgB"],
    	"method": "custom",
    "expression": "df1.unit_price * df2.units",
    "result_alias": "total_value"
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    data_providerslistInformation of data providersY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    data_aliasstringData aliasN
    key_columnstringColumn to be operatedY
    result_receiverslistList of result receiversY
    methodstringMethod for joint stat among multi-parties; Datum now supports sum, avg, var, is_investor_accredited, custom formula, etc.Y
    expressionstringComputation expression formula, used when the method field is customN
    result_aliasstringResult aliasN
  • Response

    {
      "status": 200,
    	"result": {
    	"path": "/path/to/result/file",
    	"type": "csv",
    	"extra": ""
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    msgstringSuccess or error message

Joint Machine Learning

Joint Model Training

Main features

Joint Model Training achieves distributed model training while making sure that no data provider discloses his sensitive data. The feature is enabled by the privacy-preserving AI framework Rosetta. Algorithms supported: logistic regression, linear regression, DNN, XGBoost, etc.

Instructions

  • Interface: runModelTrainTask

  • Request [POST]

    {
    	"data_providers": [
    		{
    			"name": "orgA",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
    			"label_column": "is_good",
    		"key_column": "id", 
    		"select_columns": ["col1"],
    		"discrete_columns": ["type"]
    		},
    		{
    			"name": "orgB",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
    			"label_column": "is_good",
    		"key_column": "id", 
    		"select_columns": ["col1"],
    		"discrete_cols": ["type"]
    		}
    	],
    	"result_receivers": ["orgA"],
        "algorithm": "dnn",
        "hyper_params": {"learning_rate": 0.00001, "loss": "mse"},
        "metrics": ["accuracy", "precision", "recall"],
        "model_config": {""}
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    data_providerslistInformation of all data providersY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    label_columnstringLabel columnY
    key_columnstringKey column, used for aligningN
    select_columnslistSelect the columns to be used for model training (default: all columns)N
    discrete_colslistDiscrete columns used to certain operations (e.g. embedding)N
    result_receiverslistList of result receiversY
    algorithmstringTraining algorithmY
    hyper_paramsstringHyperparameters, related to the training methodN
    metricslistMetrics of the model (default: loss)N
    model_configstringjson string that describes the complex DNN modelN
  • Response

    {
      "status": 200,
    	"result": {
          "model_id": "0xd22"
    		"path": "/path/to/model",
    		"type": "bin",
    		"extra": "",
          "metrics": {"accuracy": 0.95}
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    model_idstringModel ID
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    metricsjsonMetrics required
    msgstringSuccess or error message

Joint Model Prediction

Main features

Joint Model Prediction achieves distributed model prediction while making sure that no data provider discloses his sensitive data. The feature is enabled by the privacy-preserving AI framework Rosetta. Algorithms supported: logistic regression, linear regression, DNN, XGBoost, etc.

Instructions

  • Interface: runModelPredictTask

  • Request [POST]

    {
    	"data_providers": [
    		{
    			"name": "orgA",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
              "key_column": "id", 
    		},
    		{
    			"name": "orgB",
    			"data_path": "/path/to/data",
    			"data_type": "csv",
              "key_column": "id", 
    		}
    	],
    	"result_receivers": ["orgA"],
        "model_id": "0xd22",
        "params": {"threshold": 0.8}
    }
    

    Parameter description

    ParameterTypeDescriptionIf required
    data_providerslistInformation of all data providersY
    namestringOrganization nameY
    data_pathstringData pathY
    data_typestringData typeY
    key_columnstringKey column, used for aligningN
    result_receiverslistList of result receiversY
    model_idstringModel IDY
    paramsjsonParameterN
  • Response

    {
      "status": 200,
    	"result": {
    		"path": "/path/to/result/file",
    		"type": "csv",
    		"extra": ""
    	},
    	"msg": "success"
    }
    

    Parameter description

    ParameterTypeDescription
    statusintResponse status: 200 - success, 400 - invalid request, 500 - internal server error
    resultjsonResult information
    pathstringResult path
    typestringResult type
    extrastringAdditional information about the result
    msgstringSuccess or error message