Beispiel #1
0
import os

DIR = os.path.dirname(os.path.realpath(__file__))
HOME_DIR = DIR + "/../../../"
SYM_KEY_FILE = DIR + "/../../data/key_zeros.txt"
PRIVATE_KEY_FILE = HOME_DIR + "config/user1.pem"
CERT_FILE = HOME_DIR + "config/user1.crt"

username = "******"
print("Creating enclave")
xgb.init_client(user_name=username,
                sym_key_file=SYM_KEY_FILE,
                priv_key_file=PRIVATE_KEY_FILE,
                cert_file=CERT_FILE)
xgb.init_server(enclave_image=HOME_DIR +
                "build/enclave/xgboost_enclave.signed",
                client_list=[username])

rabit_args = {
    "DMLC_NUM_WORKER": os.environ.get("DMLC_NUM_WORKER"),
    "DMLC_NUM_SERVER": os.environ.get("DMLC_NUM_SERVER"),
    "DMLC_TRACKER_URI": os.environ.get("DMLC_TRACKER_URI"),
    "DMLC_TRACKER_PORT": os.environ.get("DMLC_TRACKER_PORT"),
    "DMLC_ROLE": os.environ.get("DMLC_ROLE"),
    "DMLC_NODE_HOST": os.environ.get("DMLC_NODE_HOST")
}

rargs = [str.encode(str(k) + "=" + str(v)) for k, v in rabit_args.items()]

xgb.rabit.init(rargs)
import securexgboost as xgb
import os

HOME_DIR = os.path.dirname(os.path.realpath(__file__)) + "/../../../../"


xgb.init_server(enclave_image=HOME_DIR + "build/enclave/xgboost_enclave.signed", log_verbosity=0)
print("Waiting for clients...")
xgb.serve(all_users=["user1"], port=50051)
import os

username = "******"
DIR = os.path.dirname(os.path.realpath(__file__))
HOME_DIR = DIR + "/../../../"
sym_key_file = DIR + "/../../data/key_zeros.txt"
priv_key_file = DIR + "/../../../config/user1.pem"
cert_file = DIR + "/../../../config/user1.crt"

print("Init user and enclave parameters")
xgb.init_client(user_name=username,
                sym_key_file=sym_key_file,
                priv_key_file=priv_key_file,
                cert_file=cert_file)
xgb.init_server(enclave_image=HOME_DIR +
                "build/enclave/xgboost_enclave.signed",
                client_list=["user1"],
                log_verbosity=0)

# Remote Attestation
print("Remote attestation")

# Note: Simulation mode does not support attestation
# pass in `verify=False` to attest()
xgb.attest()

print("Creating training matrix from encrypted file")
dtrain = xgb.DMatrix({username: HOME_DIR + "demo/data/agaricus.txt.train.enc"})

print("Creating test matrix from encrypted file")
dtest = xgb.DMatrix({username: HOME_DIR + "demo/data/agaricus.txt.test.enc"})
Beispiel #4
0
import os
import securexgboost as xgb

username = "******"
HOME_DIR = os.path.dirname(os.path.realpath(__file__)) + "/../../"
sym_key_file = HOME_DIR + "demo/data/key_zeros.txt"
priv_key_file = HOME_DIR + "config/user1.pem"
cert_file = HOME_DIR + "config/user1.crt"

xgb.init_client(user_name=username,
                sym_key_file=sym_key_file,
                priv_key_file=priv_key_file,
                cert_file=cert_file)
xgb.init_server(enclave_image=HOME_DIR +
                "build/enclave/xgboost_enclave.signed")
xgb.attest(verify=False)