How dtc2025ag/moai works
MOAI is a C++ implementation of non-interactive secure Transformer inference using CKKS, with matrix operations, nonlinear layers, and bootstrapping as major capabilities. The intended workflow is encrypted inputs processed through Transformer operations and returned as encrypted results; the README does not identify a runtime entry point, and sampled excerpts do not establish wiring among the high-level layer modules, so those links are left out. Bootstrapper’s construction of ModularReducer and its use of SEAL evaluator operations are visible in sampled source. Other subsystem relationships are based on the documented product purpose and module names.
Main entry points: Bootstrapper.cpp Bootstrapper · ckks_evaluator.cpp CKKS evaluator · evaluator.h SEAL evaluator · Batch_encode_encrypt.hpp Batch encoding
Components 17
Transformer operations
- Matrix multiplication
include/source/matrix_mul/Ct_ct_matrix_mul.hpp - Plaintext matrix
include/source/matrix_mul/Ct_pt_matrix_mul.hpp - Batch encoding
include/source/matrix_mul/Batch_encode_encrypt.hpp - GELU
include/source/non_linear_func/gelu.hpp - Other GELU
include/source/non_linear_func/gelu_others.hpp - Layer normalization
include/source/non_linear_func/layernorm.hpp - Softmax
include/source/non_linear_func/softmax.hpp
CKKS approximation
- CKKS evaluator
include/source/ckks_evaluator.cpp - Polynomial evaluation
include/source/ckks_evaluator.cpp
Bootstrapping
- Bootstrapper
include/source/bootstrapping/Bootstrapper.cpp - Modular reducer
include/source/bootstrapping/ModularReducer.cpp - Remez approximation
include/source/bootstrapping/common/Remez.cpp
HE backend
- CKKS encoder
thirdparty/SEAL-4.1-bs/native/src/seal/ckks.h - SEAL evaluator
thirdparty/SEAL-4.1-bs/native/src/seal/evaluator.h - SEAL context
thirdparty/SEAL-4.1-bs/native/src/seal/context.h
Other components
- Inference caller
- Encrypted result
Connections 17
- Inference caller → Batch encoding: provides inputs
- Batch encoding → Matrix multiplication: encodes inputs
- Inference caller → Matrix multiplication: invokes
- Inference caller → Plaintext matrix: invokes
- Inference caller → GELU: invokes
- Inference caller → Other GELU: invokes
- Inference caller → Layer normalization: invokes
- Inference caller → Softmax: invokes
- Inference caller → Bootstrapper: invokes
- Inference caller → Encrypted result: receives result
- CKKS evaluator → Polynomial evaluation: evaluates
- Bootstrapper → Modular reducer: constructs
- Bootstrapper → SEAL evaluator: uses operations
- CKKS evaluator → SEAL evaluator: calls
- CKKS evaluator → CKKS encoder: encodes constants
- Bootstrapper → Encrypted result: produces ciphertext
- SEAL context → SEAL evaluator: configures