Skip to content

Create, Register and Utilize SmartData and Policies

Smart data is a paradigm in COVA protocol that encrypts the data with a custom policy. Only a majority collection of TEE routing nodes and their eventual consensus can decrypt the dataset for running only the programs/computations allowed by the routing node.

Creating a smart data and embedding Smart Policies inside that dataset is simple due to COVA Python/JS Libraries.

Setup Library and Config Files

First, you need setup running

# cd cova-python-driver

python setup.py install

Data Owner: Config and Example Code

Data Owner must have one file in the working directory named DOConfig.conf (example). It must contain

eth_address
bdb_address
information_gain 
totalNode
minNode

Data Owner need to download all routing node information from public github and save it at routing_nodes.txt

from cova_python_driver.data_owner import *

# create smart data
DataOwnerFileProcessor(data_set_file_path, policies).run()

Example Input:

Data_set_file_path = “data_set.txt”
Policies = { 
    "pre": 
        {
            "fileHash": { 
                "equalTo": "ced15926369cf6a2a7361434908cec8c"
            }
        },
    "runtime":
        {
            "_printBytecode": {}
        },
    "post": {}
    }
Data_hash.enc (encrypted dataset, will be saved on local disk default path)
Data_hash_key.enc (encryption key, will be saved on local disk default path)

To learn more about policies and how to create them, please refer to this tutorial on how to write them.

Once these two files are created end user should upload them to some cloud services. Given the data is encrypted and can only be decrypted using COVA protocol, we can upload the data anywhere (e.g centralized servers such as aws S3 or dropbox, or decentralized storage such as IPFS etc).

# post uploading: register the data in CovaChain
DataOwnerSecretUploader(smart_data_hash, eth_wallet_id,
    eth_private_key, bdb_pub, bdb_private, download_link).run()

Currently, we have wrappers for Dropbox, which you can use to make the whole process a single step. We will update this section with further instructions, on how to use those auto-uploaders.

Data User: Config and Example Code

Data User must have one file in the working directory named DUConfig.conf. It must contain

eth_address
bdb_address
routing_node_address 
total_routing_node

Data User needs to download all routing node information from public github and save it at routing_nodes.txt

SecretUploader = DataOwnerSecretUploader(smart_data_hash, eth_wallet_id,
    eth_private_key, bdb_pub, bdb_private,download_link )

SecretUploader.run()

Example Input:

# sha-256 hash 
Smart_data_hash = “5b49353096ea64900e2d04390db0302ddcd36bc981d7a1b852687fb812b3055d”
eth_wallet_id  = “ffcf8fdee72ac11b5c542428b35eef5769c409f0”
eth_private_key = “6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1”
bdb_public_key = “C5uvE8WWGdpqV21qd7wTCd5LsFxJbAu3Q9JT4Qysbvp”
bdb_private_key = “FUkbjXzGWonJPbFtPFryhvdcbwRcfykcwf3mE6w8Mszn”
download_link = dropbox download link with dl=1

Utilize SmartData

CodeExecutor = DataUserCodeExecute(data_hash, eth_pub_key, eth_priv_key,
  timeout, code_file_path)
CodeExecutor.run()

After that user should call CodeExecutor.get_computation_result() after expected time. If code execution is completed then result will be saved in the current directory as data_hash.txt

data_hash = “5b49353096ea64900e2d04390db0302ddcd36bc981d7a1b852687fb812b3055d” 
eth_pub_key = “90f8bf6a479f320ead074411a4b0e7944ea8c9c1”
eth_priv_key = “4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d”
timeout = 1000
code_file_path = “code.txt”

Output:
    Execution result