Skip to content

Commit f1f0259

Browse files
authored
[accless] Add C++ Wrappers For abe4 Library (#41)
* [libs] Implement FFI Wrapper Of Abe4 Setup Function * [build] E: Towards C++ Tests * [build] Bump Patch Version To 0.8.1 * [accli] Include Task To Run Commands Inside Container * [accless] Towards C++ Tests * [accless] Preliminary C++ Tests For JWT * [accli] Fixes For Reproducible C++ Builds * [accless] Add Base64 Library * [accless] Add KeyGen FFI Wrapper In Abe4 * [accless] Add Encrypt FFI Wrapper For Abe4 * [accless] Add Decrypt FFI Wrapper For abe4 * [accless] Add API Tests For The C++ FFI Library * [accless] Remove Stale test.cpp File From Jwt Lib * [ci] Fix cpp-unit-tests Job
1 parent 27ac456 commit f1f0259

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2389
-388
lines changed

.github/workflows/tests.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ concurrency:
1717
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1818

1919
jobs:
20-
unit-tests:
20+
checks:
21+
if: github.event.pull_request.draft == false
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- name: "Checkout code"
25+
uses: actions/checkout@v4
26+
- name: "Install clang-format"
27+
run: sudo apt install -y clang-format
28+
- name: "Run formatting checks"
29+
run: ./scripts/accli_wrapper.sh dev format-code
30+
31+
rust-unit-tests:
2132
if: github.event.pull_request.draft == false
2233
runs-on: ubuntu-24.04
2334
steps:
@@ -26,16 +37,19 @@ jobs:
2637
- name: "Run Rust unit tests"
2738
run: |
2839
source ./scripts/workon.sh
29-
# TODO: move to accli dev test
3040
cargo test
3141
32-
checks:
42+
cpp-unit-tests:
3343
if: github.event.pull_request.draft == false
3444
runs-on: ubuntu-24.04
3545
steps:
3646
- name: "Checkout code"
3747
uses: actions/checkout@v4
38-
- name: "Install clang-format"
39-
run: sudo apt install -y clang-format
40-
- name: "Run formatting checks"
41-
run: ./scripts/accli_wrapper.sh dev format-code
48+
- name: "Build C++ code"
49+
shell: bash
50+
run: |
51+
./scripts/accli_wrapper.sh docker run --mount --cwd /code/accless/accless python3 build.py
52+
- name: "Run C++ unit tests"
53+
shell: bash
54+
run: |
55+
./scripts/accli_wrapper.sh docker run --mount --cwd /code/accless/accless/build-native ctest -- --output-on-failure

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
# Rust builds
12
target
23

3-
workflows/build
4+
# Python builds
45
venv
6+
venv-bm
57

8+
# C++ builds
69
build-native
710
build-wasm
811

912
ansible/inventory/vms.ini
1013

1114
datasets*
15+
16+
gemini-plans

Cargo.lock

Lines changed: 18 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ members = [
1212
]
1313

1414
[workspace.package]
15-
version = "0.8.0"
15+
version = "0.8.1"
1616
license-file = "LICENSE"
1717
authors = ["Large-Scale Data & Systems Group - Imperial College London"]
1818
edition = "2024"
@@ -27,6 +27,7 @@ ark-bls12-381 = "0.4.0"
2727
ark-mnt4-298 = "0.4.0"
2828
ark-ec = "0.4.2"
2929
ark-ff = "0.4.2"
30+
ark-serialize = "0.4.2"
3031
ark-std = "0.4.0"
3132
axum = "0.7"
3233
base64 = "^0.22"
@@ -49,7 +50,7 @@ once_cell = "^1.19.0"
4950
p256 = "0.13.2"
5051
plotters = "^0.3.7"
5152
rabe = { git = "https://github.com/faasm/rabe.git", rev = "0dc7696a95eef44dd051e1d9c2e5c2c8c35211bf" }
52-
rand = "0.9.2"
53+
rand = "0.8.5"
5354
regex = "1"
5455
reqwest = "0.12.24"
5556
ring = "0.17.14"
@@ -58,6 +59,7 @@ rustls = "0.23"
5859
rustls-pemfile = "1"
5960
serde = { version = "^1.0", features = ["derive"] }
6061
serde_json = "^1.0"
62+
serde_with = "3.8.1"
6163
serde_yaml = "0.9"
6264
shellexpand = "^3.1"
6365
sha2 = "0.10"

GEMINI.md

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,66 @@ You can run the code formatting checks with:
5959

6060
```bash
6161
# To format code.
62-
accli dev format-code
62+
./scripts/accli_wrapper.sh dev format-code
6363

6464
# To check formatting.
65-
accli dev format-code --check
65+
./scripts/accli_wrapper.sh dev format-code --check
6666
```
6767

68-
after applying any changes, make sure they compile by running:
68+
note that in order to set the right environment for your commands, we provide
69+
the `./scripts/accli_wrapper.sh` that you should use whenever you want to
70+
run a commadn in `accli`. All commands and subcommands in `accli` take an
71+
optional `--help` flag: `./scrips/accli_wrapper.sh --help`.
6972

70-
```bash
71-
cargo build
72-
```
73-
74-
## Code Style
73+
## Coding Guideleins
7574

7675
- Whenever you edit a file, make sure you add a trailing newline to the end of
7776
the file.
78-
- In rust code, do not allow the use of unwrap() or panic(). Instead, enforce
79-
proper error handling.
77+
- For each new function you add, make sure to add one or multiple unit tests.
78+
79+
### Rust Coding Guidelines
80+
81+
- Whenever you make changes to rust source code, make sure to build it and test
82+
it with: `cargo build` and `cargo test` from the root of the directory.
83+
- Do not allow the use of unwrap() or panic(). Instead, enforce proper error handling.
84+
- For each new method, make sure to add extensive documentation in the following format:
85+
```rust
86+
///
87+
/// # Description
88+
///
89+
/// <description>
90+
///
91+
/// # Arguments
92+
///
93+
/// - `arg1`: explanation
94+
/// - `arg2`: explanation
95+
///
96+
/// # Returns
97+
///
98+
/// <explanation of return value>
99+
///
100+
/// # Example Usage
101+
///
102+
/// <code snippet if applicable
103+
```
104+
105+
### C++ Coding Guidelines
106+
107+
C++ code has certain dependencies, including a cross-compilation toolchain and
108+
system root, that we only ship inside a container. As a consequence, any
109+
time you need to test some C++ feature, you need to run the command inside
110+
the sysroot container. To do so, you may use `accli` as follows:
111+
112+
```
113+
# <cwd> must be an absolute path!
114+
./scripts/accli_wrapper.sh docker run [--cwd <cwd>] [--mount] "<your bash command here>"
115+
```
116+
117+
After doing any C++ code modifications, make sure to format the code, and run
118+
the tests:
119+
120+
```
121+
./scripts/accli_wrapper.sh dev format-code
122+
./scripts/accli_wrapper.sh docker run --cwd /code/accless/accless --mount python3 build.py
123+
./scripts/accli_wrapper.sh docker run --cwd /code/accless/accless/build-native --mount ctest -- --output-on-failure
124+
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.0
1+
0.8.1

accless/CMakeLists.txt

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ set(CMAKE_PROJECT_TARGET accless)
1616
set(CMAKE_CXX_STANDARD 20)
1717
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1818

19+
# Hints to find the custom libriares that we install in the docker container:
20+
# ./config/docker/accless-experiments.dockerfile
21+
if (NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
22+
# Third-party deps for native builds.
23+
include(cmake/NativeExternalProjects.cmake)
24+
25+
# Make custom prefixes visible to *all* find_package() calls in subdirs
26+
list(PREPEND CMAKE_PREFIX_PATH
27+
"/usr/local/attestationssl"
28+
"/usr/local/attestationcurl"
29+
)
30+
31+
# OpenSSL hints
32+
set(OPENSSL_ROOT_DIR "/usr/local/attestationssl" CACHE PATH "")
33+
set(OPENSSL_USE_STATIC_LIBS ON CACHE BOOL "")
34+
set(OPENSSL_INCLUDE_DIR "/usr/local/attestationssl/include" CACHE PATH "")
35+
set(OPENSSL_CRYPTO_LIBRARY "/usr/local/attestationssl/lib64/libcrypto.a" CACHE FILEPATH "")
36+
set(OPENSSL_SSL_LIBRARY "/usr/local/attestationssl/lib64/libssl.a" CACHE FILEPATH "")
37+
38+
# Curl hints
39+
set(CURL_INCLUDE_DIR "/usr/local/attestationcurl/include" CACHE PATH "")
40+
set(CURL_LIBRARY "/usr/local/attestationcurl/lib/libcurl.a" CACHE FILEPATH "")
41+
endif ()
42+
1943
add_library(${CMAKE_PROJECT_TARGET}
2044
./src/accless.cpp
2145
./src/dag.cpp
@@ -32,14 +56,16 @@ endif ()
3256

3357
# Common libraries and headers that support WASM and native compilation
3458
add_subdirectory(./libs/jwt/cpp-bindings)
35-
add_subdirectory(./libs/rabe/cpp-bindings)
59+
add_subdirectory(./libs/abe4/cpp-bindings)
60+
add_subdirectory(./libs/base64)
3661

3762
set(ACCLESS_COMMON_HEADERS
3863
${CMAKE_CURRENT_LIST_DIR}/include
3964
${CMAKE_CURRENT_LIST_DIR}/libs/jwt/cpp-bindings
40-
${CMAKE_CURRENT_LIST_DIR}/libs/rabe/cpp-bindings
65+
${CMAKE_CURRENT_LIST_DIR}/libs/abe4/cpp-bindings
66+
${CMAKE_CURRENT_LIST_DIR}/libs/base64
4167
)
42-
set(ACCLESS_COMMON_LIBRARIES accless::jwt accless::rabe)
68+
set(ACCLESS_COMMON_LIBRARIES accless::jwt accless::abe4 accless::base64)
4369

4470
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
4571
# The WASM version of the library relies on a pre-populated sysroot as part
@@ -56,6 +82,8 @@ else ()
5682
/usr/local/attestationssl/lib64
5783
)
5884

85+
target_compile_options(${CMAKE_PROJECT_TARGET} PRIVATE -Wno-deprecated-declarations)
86+
5987
# The WASM version of the attestation and S3 libraries is part of Faasm
6088
# because it needs to execute (partially) outside of the WASM module
6189
# and outside of the enclave
@@ -91,3 +119,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
91119
endif ()
92120

93121
add_library(accless::accless ALIAS accless)
122+
123+
if (NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
124+
add_subdirectory(tests)
125+
endif()

accless/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Accless Core Library
2+
3+
To build:
4+
5+
```bash
6+
accli docker run --mount --cwd /code/accless/accless python3 build.py [-- --clean]
7+
```
8+
9+
To test:
10+
11+
```bash
12+
accli docker run --mount --cwd /code/accless/accless/build-native ctest -- --output-on-failure
13+
```

0 commit comments

Comments
 (0)