Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds 3 mvp enclave functions #5

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app/Enclave_u.c
app/Enclave_u.h
enclave/Enclave_t.c
enclave/Enclave_t.h
46 changes: 46 additions & 0 deletions utils/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Dummy makefile, will call the host and enclave makefile when requested.

SRC_U = app/
SRC_T = enclave/

# Compilation process, will call the appropriate makefiles.

all: host enclave

host:
@echo "\033[32mRequest to compile the host part...\033[0m"
@make -C $(SRC_U)

enclave:
@echo "\033[32mRequest to compile the enclave part...\033[0m"
@make -C $(SRC_T)

clean:
@make -C $(SRC_U) clean
@make -C $(SRC_T) clean

fclean:
@make -C $(SRC_U) fclean
@make -C $(SRC_T) fclean

clean_host:
@make -C $(SRC_U) clean

clean_enclave:
@make -C $(SRC_T) clean

fclean_host:
@make -C $(SRC_U) fclean

fclean_enclave:
@make -C $(SRC_T) fclean

re_host: fclean_host host

re_enclave: fclean_enclave enclave

re: fclean all

# Dummy rules to let make know that those rules are not files.

.PHONY: host enclave clean clean_host clean_enclave fclean_host fclean_enclave fclean re re_host re_enclave
77 changes: 77 additions & 0 deletions utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# setup

For the Python part, we use [Poetry] for package management.

- On the Debian family of OSes, install it so:

```
apt install python3-poetry
```

- Proceed by navigating to a directory containing "pyproject.toml",
then use `poetry` to install some needed packages:

```
cd utils/app
poetry install
```

- Open the Python environment by running `poetry shell`.
You will know this worked by seeing something similar to the following,
after running each shell command:

> (utils-py3.11)

- Create a `.env` file indicating that this is just a simulation:

```
cd ..
echo 'export SGX_DEBUG_MODE=1' > .env
```

- While there,
point to where the shared object is located:

```
echo 'export ENCLAVE_SHARED_OBJECT=../build/bin/enclave.signed.so' >> .env
```

- Source the Intel SGX SDK env,
created by following instructions from [this repo].

# build

- Navigate to the root of the project,
and build it so:

```
cd ..
make
```

- To create the Python bindings:

```
cd app
maturin develop
```

Note that `maturin` is installed in the Python env with `poetry install` above.

# test

Navigate to `app/`, run the Python shell, import `utils`, and play.

The following shows some examples:

```
$ python -c 'from utils import row_counter as run; out = run("[1, 2, 3]"); print(out)'
3
$ python -c 'from utils import dataset_hashing as run; out = run("foo"); print(out)'
04e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9
$ python -c 'from utils import dataset_append as run; out = run("[1, 2, 3]", "[4, 5, 6]"); print(out)'
('[1,2,3,4,5,6]', '3b27ea06e1a721ca6709a283026372e7ff388331242dac94548544b35c2db9b6')
````

[Poetry]: https://python-poetry.org
[this repo]: https://github.com/ntls-io/rust-sgx-sdk-dev-env
Loading