Skip to content

yizhiru/toy-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toy-crypto

A multi-language cryptographic algorithm library covering both classical Chinese national standard (SM series) algorithms and post-quantum cryptographic algorithms.

Project Structure

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

Algorithms

C — SM Series (Chinese National Standard)

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)

Rust — Post-Quantum Cryptography

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

Build

C (SM3 / SM4)

Requires CMake 3.23+ and a C99 compiler.

cd c
mkdir build && cd build
cmake ..
make

The library and headers are output to c/release/.

To run tests:

cd c/build
ctest

Rust (SPHINCS+)

Requires Rust toolchain (cargo).

cd rust/sphincs_plus
cargo build --release
cargo test

To run benchmarks:

cargo bench

License

MIT

About

Toy implementations of cryptographic algorithms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors