Initial commit

BSD-3-Clause-Research License: Pure Go TFHE implementation with
patent-pending innovations including deterministic FHE for blockchain
consensus, transaction-batch amortized bootstrapping, and parallel
bootstrapping with work-stealing scheduler.
This commit is contained in:
Zach Kelling
2025-12-28 18:04:25 -08:00
commit c68dea0a9f
1798 changed files with 622473 additions and 0 deletions
+242
View File
@@ -0,0 +1,242 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-go:
name: Go Tests (${{ matrix.go-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
go-version: ['1.21', '1.22', '1.23']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Download dependencies
run: go mod download
- name: Build
env:
CGO_ENABLED: '0'
run: go build ./...
- name: Test (Unix)
if: runner.os != 'Windows'
env:
CGO_ENABLED: '0'
run: go test -v -timeout 30m -coverprofile=coverage.out .
- name: Test (Windows)
if: runner.os == 'Windows'
env:
CGO_ENABLED: '0'
run: go test -v -timeout 30m .
- name: Upload coverage
if: matrix.go-version == '1.23' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out
test-c:
name: C SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build C shared library
run: |
mkdir -p sdk/c/lib
CGO_ENABLED=1 go build -buildmode=c-shared -o sdk/c/lib/libluxfhe.so ./sdk/c/src/luxfhe.go
- name: Verify library exports
run: |
nm -D sdk/c/lib/libluxfhe.so | grep luxfhe | head -20
- name: Upload C library
uses: actions/upload-artifact@v4
with:
name: libluxfhe-linux
path: sdk/c/lib/libluxfhe.so
test-wasm:
name: WASM SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build WASM
run: |
GOOS=js GOARCH=wasm go build -o sdk/wasm/luxfhe.wasm ./sdk/wasm/main.go
ls -lh sdk/wasm/luxfhe.wasm
- name: Upload WASM
uses: actions/upload-artifact@v4
with:
name: luxfhe-wasm
path: sdk/wasm/luxfhe.wasm
test-typescript:
name: TypeScript SDK (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ['18', '20', '22']
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
working-directory: sdk/typescript
run: npm ci
- name: Type check
working-directory: sdk/typescript
run: npm run typecheck
- name: Build
working-directory: sdk/typescript
run: npm run build
- name: Upload TypeScript dist
if: matrix.node-version == '22'
uses: actions/upload-artifact@v4
with:
name: luxfhe-ts
path: sdk/typescript/dist
test-rust:
name: Rust SDK
runs-on: ubuntu-latest
needs: test-c
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Download C library
uses: actions/download-artifact@v4
with:
name: libluxfhe-linux
path: sdk/c/lib
- name: Install libclang for bindgen
run: sudo apt-get update && sudo apt-get install -y libclang-dev
- name: Check Rust bindings
working-directory: sdk/rust
run: cargo check
- name: Build Rust bindings
working-directory: sdk/rust
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/sdk/c/lib
run: cargo build --release
test-python:
name: Python SDK (${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: test-c
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download C library
uses: actions/download-artifact@v4
with:
name: libluxfhe-linux
path: sdk/c/lib
- name: Install dependencies
working-directory: sdk/python
run: |
pip install cffi pytest
pip install -e .
- name: Run tests
working-directory: sdk/python
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/sdk/c/lib
run: pytest -v tests/
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Run benchmarks
env:
CGO_ENABLED: '0'
run: go test -bench=BenchmarkLattice -benchmem -run=^$ . | tee benchmark.txt
- name: Upload benchmark
uses: actions/upload-artifact@v4
with:
name: benchmark
path: benchmark.txt
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Run go vet
env:
CGO_ENABLED: '0'
run: go vet ./...
- name: Run go fmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files need to be formatted:"
gofmt -s -l .
exit 1
fi
+66
View File
@@ -0,0 +1,66 @@
name: Deploy Docs to GitHub Pages
on:
push:
branches: [main]
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: docs/pnpm-lock.yaml
- name: Install dependencies
working-directory: docs
run: pnpm install
- name: Build docs
working-directory: docs
run: pnpm build
- name: Setup Pages
uses: actions/configure-pages@v5
with:
enablement: true
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/out
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
+251
View File
@@ -0,0 +1,251 @@
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v0.1.0)'
required: true
type: string
permissions:
contents: write
jobs:
build-binaries:
name: Build (${{ matrix.os }}, ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux
- os: linux
arch: amd64
runner: ubuntu-latest
ext: ''
- os: linux
arch: arm64
runner: ubuntu-latest
ext: ''
# macOS
- os: darwin
arch: amd64
runner: macos-latest
ext: ''
- os: darwin
arch: arm64
runner: macos-latest
ext: ''
# Windows
- os: windows
arch: amd64
runner: windows-latest
ext: '.exe'
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: '0'
run: |
go build -ldflags="-s -w" -o luxfhe-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} ./cmd/fhe-server/
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: luxfhe-${{ matrix.os }}-${{ matrix.arch }}
path: luxfhe-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}
build-c-libraries:
name: C Library (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-latest
lib: libluxfhe.so
- os: darwin
runner: macos-latest
lib: libluxfhe.dylib
- os: windows
runner: windows-latest
lib: luxfhe.dll
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build C shared library
shell: bash
run: |
mkdir -p dist
CGO_ENABLED=1 go build -buildmode=c-shared -o dist/${{ matrix.lib }} ./sdk/c/src/luxfhe.go
- name: Upload C library
uses: actions/upload-artifact@v4
with:
name: libluxfhe-${{ matrix.os }}
path: dist/
build-wasm:
name: WASM Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build WASM
run: |
mkdir -p dist
GOOS=js GOARCH=wasm go build -o dist/luxfhe.wasm ./sdk/wasm/main.go
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" dist/
- name: Upload WASM
uses: actions/upload-artifact@v4
with:
name: luxfhe-wasm
path: dist/
build-typescript:
name: TypeScript SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install and build
working-directory: sdk/typescript
run: |
npm ci
npm run build
- name: Package
working-directory: sdk/typescript
run: npm pack
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: luxfhe-typescript
path: sdk/typescript/*.tgz
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-binaries, build-c-libraries, build-wasm, build-typescript]
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
# Binaries
for dir in artifacts/luxfhe-*; do
if [ -d "$dir" ]; then
name=$(basename "$dir")
if [[ "$name" == luxfhe-linux-* ]] || [[ "$name" == luxfhe-darwin-* ]] || [[ "$name" == luxfhe-windows-* ]]; then
for f in "$dir"/*; do
cp "$f" "release/"
done
fi
fi
done
# C libraries
for os in linux darwin windows; do
if [ -d "artifacts/libluxfhe-$os" ]; then
tar -czvf "release/libluxfhe-$os.tar.gz" -C "artifacts/libluxfhe-$os" .
fi
done
# WASM
if [ -d "artifacts/luxfhe-wasm" ]; then
tar -czvf "release/luxfhe-wasm.tar.gz" -C "artifacts/luxfhe-wasm" .
fi
# TypeScript
if [ -d "artifacts/luxfhe-typescript" ]; then
cp artifacts/luxfhe-typescript/*.tgz release/
fi
ls -la release/
- name: Generate checksums
run: |
cd release
sha256sum * > checksums.txt
cat checksums.txt
- name: Get tag name
id: tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: LuxFHE ${{ steps.tag.outputs.tag }}
body: |
## LuxFHE ${{ steps.tag.outputs.tag }}
Pure Go implementation of TFHE (Torus Fully Homomorphic Encryption).
### Downloads
#### CLI Binary
| Platform | Architecture | Download |
|----------|--------------|----------|
| Linux | amd64 | `luxfhe-linux-amd64` |
| Linux | arm64 | `luxfhe-linux-arm64` |
| macOS | amd64 | `luxfhe-darwin-amd64` |
| macOS | arm64 | `luxfhe-darwin-arm64` |
| Windows | amd64 | `luxfhe-windows-amd64.exe` |
#### SDK Libraries
- `libluxfhe-linux.tar.gz` - C shared library for Linux
- `libluxfhe-darwin.tar.gz` - C shared library for macOS
- `libluxfhe-windows.tar.gz` - C DLL for Windows
- `luxfhe-wasm.tar.gz` - WebAssembly build
- `luxfhe-*.tgz` - TypeScript/JavaScript SDK
### Verification
Verify downloads with checksums:
```bash
sha256sum -c checksums.txt
```
files: release/*
draft: false
prerelease: ${{ contains(steps.tag.outputs.tag, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}