Skip to content

Commit be773d3

Browse files
committed
checkin trying to make it compile to SGX
1 parent f43b9c3 commit be773d3

14 files changed

Lines changed: 8544 additions & 2 deletions

.github/workflows/sgx.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: SGX Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, 'feat/**' ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-sgx:
11+
name: Build SGX Enclave
12+
runs-on: ubuntu-22.04
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Build TypeScript project
27+
run: npm run build
28+
29+
- name: Install Gramine
30+
run: |
31+
sudo curl -fsSLo /usr/share/keyrings/gramine-keyring.gpg https://packages.gramineproject.io/gramine-keyring.gpg
32+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/gramine-keyring.gpg] https://packages.gramineproject.io/ $(lsb_release -sc) main" \
33+
| sudo tee /etc/apt/sources.list.d/gramine.list
34+
sudo apt-get update
35+
sudo apt-get install -y gramine
36+
37+
- name: Verify Gramine installation
38+
run: |
39+
gramine-manifest --version
40+
gramine-sgx-sign --version
41+
42+
- name: Build SGX manifest
43+
run: |
44+
cd sgx
45+
make shield.manifest
46+
47+
- name: Verify manifest syntax
48+
run: |
49+
test -f sgx/shield.manifest
50+
echo "✓ Manifest file created successfully"
51+
52+
- name: Test entrypoint
53+
run: |
54+
node -c sgx/entrypoint.js
55+
echo "✓ Entrypoint syntax valid"
56+
57+
- name: Upload build artifacts
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: sgx-manifest
61+
path: sgx/shield.manifest
62+
retention-days: 7
63+
64+
build-docker:
65+
name: Build Docker Image
66+
runs-on: ubuntu-22.04
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
73+
74+
- name: Build Docker image
75+
uses: docker/build-push-action@v5
76+
with:
77+
context: .
78+
file: sgx/Dockerfile
79+
push: false
80+
tags: shield-sgx:test
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max
83+
84+
- name: Test Docker image (direct mode)
85+
run: |
86+
docker run -d --name shield-test \
87+
-p 8080:8080 \
88+
-e NODE_ENV=production \
89+
shield-sgx:test make run-direct
90+
91+
# Wait for server to start
92+
sleep 5
93+
94+
# Test health endpoint
95+
curl -f http://localhost:8080/health | jq .
96+
97+
# Stop container
98+
docker stop shield-test
99+
docker rm shield-test
100+
101+
lint-sgx-config:
102+
name: Lint SGX Configuration
103+
runs-on: ubuntu-latest
104+
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Check required files
109+
run: |
110+
test -f sgx/entrypoint.js || (echo "Missing entrypoint.js" && exit 1)
111+
test -f sgx/shield.manifest.template || (echo "Missing manifest template" && exit 1)
112+
test -f sgx/config.mk || (echo "Missing config.mk" && exit 1)
113+
test -f sgx/Makefile || (echo "Missing Makefile" && exit 1)
114+
test -f sgx/Dockerfile || (echo "Missing Dockerfile" && exit 1)
115+
test -f sgx/README.md || (echo "Missing README" && exit 1)
116+
echo "✓ All required SGX files present"
117+
118+
- name: Validate manifest template syntax
119+
run: |
120+
# Check for common syntax errors
121+
grep -q "loader.entrypoint" sgx/shield.manifest.template
122+
grep -q "sgx.enclave_size" sgx/shield.manifest.template
123+
grep -q "sgx.trusted_files" sgx/shield.manifest.template
124+
echo "✓ Manifest template syntax looks good"
125+
126+
- name: Validate Makefile
127+
run: |
128+
cd sgx
129+
make -n build || echo "⚠ Makefile dry-run had warnings (expected on non-SGX system)"

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ coverage/
4444
*.tmp
4545
*.temp
4646
.tmp/
47-
.temp/
47+
.temp/
48+
49+
# SGX build artifacts
50+
sgx/*.manifest
51+
sgx/*.manifest.sgx
52+
sgx/*.sig
53+
sgx/*.token
54+
sgx/OUTPUT/

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
npm install @yieldxyz/shield
1717
```
1818

19+
## 🔒 Intel SGX Support
20+
21+
Shield can run inside an Intel SGX enclave for hardware-level security guarantees. See [sgx/README.md](./sgx/README.md) for details.
22+
23+
```bash
24+
# Quick start with SGX
25+
npm run sgx:build
26+
npm run sgx:run
27+
```
28+
1929
## Usage
2030

2131
```typescript

0 commit comments

Comments
 (0)