Crypto3 is a modular, header-only C++ cryptography suite. It provides generic, STL-style interfaces for cryptographic primitives and the algebraic and mathematical structures used to build them.
Initially developed by =nil; Crypto3, the
project is now maintained by [[alloc] init]. Guides are
available under docs/manual.
Continuous integration currently covers Ubuntu x86-64 and macOS. Other operating systems and architectures are not continuously tested.
Crypto3 is maintained as a monorepo. The source trees under libs are regular
directories in this repository; cmake/modules is the only Git submodule.
root
|-- cmake
| `-- modules BoostCMake helper submodule
|-- docs Doxygen configuration and guides
`-- libs
|-- algebra Finite fields, curves, and pairings
|-- benchmark_tools Shared benchmark utilities
|-- block Block ciphers
|-- codec Encoding and decoding algorithms
|-- containers Merkle trees and related containers
|-- hash Hash functions
|-- kdf Key derivation functions, including PBKDF2
|-- mac Message authentication codes
|-- marshalling Algebra, container, math, and numeric marshalling
|-- math Polynomial arithmetic and FFT algorithms
|-- modes Cipher mode headers and tests
|-- multiprecision Extended multiprecision types and utilities
|-- pkpad Public-key padding schemes
|-- pubkey Public-key schemes and secret sharing
|-- random Randomization primitives
|-- stream Stream ciphers
`-- zk Zero-knowledge proof systems
- CMake 3.22 or newer
- A C++23-capable C++ compiler
- Boost with the
container,random,filesystem,log,log_setup,program_options,thread,unit_test_framework, andtimercomponents - Git
- Doxygen and Graphviz when building the API documentation
The build does not enforce a specific Boost version. CI currently builds on Ubuntu 26.04 with its distribution compiler and on macOS 26 with Homebrew LLVM.
The submodule URL uses GitHub SSH. If you do not have GitHub SSH credentials, configure this checkout to fetch GitHub dependencies over HTTPS:
git clone https://github.com/alloc-init/crypto3.git
cd crypto3
git config url."https://github.com/".insteadOf [email protected]:
git submodule update --init --recursive
cmake -S . -B build -DBUILD_TESTS=ON
cmake --build build --target tests --parallel
ctest --test-dir build --output-on-failureUseful CMake options include:
BUILD_TESTS: configure tests; defaults toONBUILD_BENCH_TESTS: configure performance benchmarks; defaults toOFFBUILD_DOCS: configure Doxygen documentation support; defaults toOFFBUILD_EXAMPLES: build component examples; defaults toOFFBUILD_WITH_TARGET_ARCHITECTURE: override automatic target architecture detection
Generate the API documentation under build/docs with:
cmake -S . -B build -DBUILD_DOCS=ON
cmake --build build --target docsOn Apple Silicon, install the dependencies with brew install boost llvm and
select Homebrew Clang when configuring:
cmake -S . -B build \
-DBUILD_TESTS=ON \
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++Crypto3 components are header-only CMake INTERFACE libraries. In a CMake
project that includes Crypto3, link only the components you use:
add_subdirectory(path/to/crypto3)
target_link_libraries(my_target PRIVATE crypto3::hash crypto3::algebra)Component dependencies are expressed by their CMake targets. Buildable examples
are located in component-specific libs/*/example directories. See the
quickstart for an in-tree example.
See the contribution guidelines.
- Email: [email protected]
- Telegram: @alloc-init
- GitHub issues
- GitHub Discussions
The software is provided under the MIT License.