A multi-language cryptographic algorithm library covering both classical Chinese national standard (SM series) algorithms and post-quantum cryptographic algorithms.
toyCrypto/
├── c/ # C implementations
│ ├── CMakeLists.txt
│ ├── include/ # Public headers
│ │ ├── crypto.h
│ │ ├── sm3.h
│ │ └── sm4.h
│ ├── src/ # Source code
│ │ ├── common/ # Common utilities
│ │ ├── sm3/ # SM3 hash algorithm
│ │ └── sm4/ # SM4 block cipher
│ └── test/ # Unit tests (CuTest)
│ ├── sm3_test.c
│ └── sm4_test.c
└── rust/ # Rust implementations
└── sphincs_plus/ # SPHINCS+ (SLH-DSA) digital signature
├── Cargo.toml
├── benches/ # Criterion benchmarks
└── src/
├── spx.rs # Key generation, sign, verify
├── wots.rs # WOTS+ one-time signature
├── fors.rs # FORS few-time signature
├── xmss.rs # XMSS Merkle tree signature
├── hyper_tree.rs # Hyper-tree structure
└── hash/ # Hash function backends
| Algorithm | Type | Description |
|---|---|---|
| SM3 | Hash | 256-bit cryptographic hash function (GB/T 32905-2016) |
| SM4 | Block Cipher | 128-bit block cipher with 128-bit key (GB/T 32907-2016) |
| Algorithm | Type | Description |
|---|---|---|
| SPHINCS+ (SLH-DSA) | Digital Signature | Stateless hash-based signature scheme, NIST PQC standard |
SPHINCS+ supports the full parameter matrix:
- Security levels: 128, 192, 256
- Tradeoffs:
f(fast signing) /s(small signature) - Hash families: SHAKE, SHA-2, Haraka
- Variants: Simple / Robust
Requires CMake 3.23+ and a C99 compiler.
cd c
mkdir build && cd build
cmake ..
makeThe library and headers are output to c/release/.
To run tests:
cd c/build
ctestRequires Rust toolchain (cargo).
cd rust/sphincs_plus
cargo build --release
cargo testTo run benchmarks:
cargo bench