Modern, ultra-fast, zero-dependency cryptography library for Go 1.22+ Implemented using only the standard library. Battle-tested primitives, minimal attack surface, ergonomic APIs.
- Small and auditable: pure Go, no third-party dependencies.
- Reduced attack surface: shared, tested internal primitives and minimal cross-package APIs.
- Consistent, ergonomic interfaces: uniform AEAD, hashing, KDF, signature, and ECDH APIs for easy composition.
- Practical security defaults: spec-aligned choices, selective zeroisation of sensitive buffers, constant-time behavior where required.
- Robust test coverage and regression protection: known-answer tests, Wycheproof-inspired suites, and fuzzing harnesses.
- Interoperability for real-world use: implements widely used constructions without exposing low-level implementation details.
- Go 1.22+
go get github.com/AeonDave/cryptonite-go- Mainstream: AES-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305, AES-GCM-SIV
- Lightweight: ASCON-128a/80pq (NIST winner), Xoodyak, GIFT-COFB, SKINNY, Deoxys-II
- Nonce-misuse resistant: AES-SIV, AES-GCM-SIV
- Fast: BLAKE2b/s (742 MB/s), SHA-3 family
- Streaming: SHAKE128/256, BLAKE2 XOF, Xoodyak
- Specialized: TupleHash, ParallelHash (SP 800-185)
- Modern: HKDF-SHA256/BLAKE2b, Argon2id, scrypt
- Password: PBKDF2-SHA1/SHA256
- MAC: HMAC-SHA256, Poly1305 (3+ GB/s)
- Stream: ChaCha20, XChaCha20, AES-CTR
- Signatures: Ed25519, ECDSA P-256
- Key Exchange: X25519, ECDH P-256/P-384
- Post-Quantum: Hybrid X25519+ML-KEM ready (via
pqpackage)
Full algorithm matrix with specs: See docs/ALGORITHMS.md
package main
import (
"fmt"
"github.com/AeonDave/cryptonite-go/aead"
)
func main() {
cipher := aead.NewAscon128()
key := make([]byte, 16)
nonce := make([]byte, 16)
ciphertext, _ := cipher.Encrypt(key, nonce, []byte("header"), []byte("secret data"))
plaintext, _ := cipher.Decrypt(key, nonce, []byte("header"), ciphertext)
fmt.Println(string(plaintext)) // "secret data"
}import "github.com/AeonDave/cryptonite-go/hash"
hasher := hash.NewBlake2bHasher()
digest := hasher.Hash([]byte("hello world"))
fmt.Printf("%x\n", digest)import "github.com/AeonDave/cryptonite-go/ecdh"
x25519 := ecdh.NewX25519()
alicePriv, _ := x25519.GenerateKey()
bobPriv, _ := x25519.GenerateKey()
aliceShared, _ := x25519.SharedSecret(alicePriv, bobPriv.PublicKey())
bobShared, _ := x25519.SharedSecret(bobPriv, alicePriv.PublicKey())
// aliceShared == bobSharedimport "github.com/AeonDave/cryptonite-go/sig"
pub, priv, _ := sig.GenerateKey()
signature := sig.Sign(priv, []byte("message"))
valid := sig.Verify(pub, []byte("message"), signature)- All tests:
go test ./... - With race detector:
go test -race ./...
Tests include KAT suites for ASCON, Xoodyak, ChaCha20‑Poly1305, AES-GCM-SIV, and AES-SIV (RFC 5297), plus tamper checks on tags and ciphertext.
Benchmark environment: AMD Ryzen 7, Go 1.23, -benchmem
| Category | Algorithm | Throughput | Allocs/op | B/op |
|---|---|---|---|---|
| AEAD | AES-GCM (AES-NI) | 1488 MB/s | 0 | 0 |
| ChaCha20-Poly1305 | 178 MB/s | 3 | 224 | |
| ASCON-128a ⭐ | 223 MB/s | 3 | 208 | |
| Hash | BLAKE2b-512 | 742 MB/s | 2 | 128 |
| SHA3-256 | 38 MB/s | 1 | 32 | |
| MAC | Poly1305 | 3117 MB/s | 4 | 64 |
| Stream | ChaCha20 | 224 MB/s | 0 | 0 |
| Sig | Ed25519 Sign | 8 MB/s | 1 | 96 |
| Ed25519 Verify | 23 MB/s | 0 | 0 | |
| ECDH | X25519 | 0.82 MB/s | 1 | 64 |
Highlights:
- Zero allocations on hot paths (AES, ChaCha20, signature verify)
- Hardware acceleration (AES-NI) when available
- Competitive with specialized C libraries
These commands exercise the encryption/decryption, hashing, KDF, MAC, stream, block, signature, ECDH, HPKE, post-quantum, and secret-management benchmarks added alongside the existing test vectors.
Symmetric protection remains classical (AEAD); only the key agreement layer is made hybrid/PQ-ready following the recommendations from draft-ietf-tls-hybrid-design.
Full benchmarks: benchmark.md Run locally:
go test ./test/... -bench=. -benchmemOn Windows PowerShell, quote the empty test pattern with double quotes:
go test ./test/... -run="^$" -bench . -benchmem -count=1- Constant-time operations where required (Poly1305, X25519, Ed25519)
- Automatic key/nonce zeroization via
secretpackage helpers - Wycheproof test vectors + fuzzing harnesses
- No CGO → reduced supply chain risk
- This library has NOT been independently audited. Even though it is deployed in production, perform thorough internal review and threat modeling before upgrading or integrating it into new systems.
- Nonce management: Caller responsible for uniqueness (use
secret.NewNonce()or counters) - Side channels: Best-effort mitigation; validate in your threat model
- Algorithm selection: Some primitives are experimental (e.g., GIFT-COFB) – prefer mainstream options (AES-GCM, ChaCha20) unless you need specific properties
Security vulnerabilities: open a private advisory via GitHub.
See SECURITY.md for full policy.
- API Docs: pkg.go.dev/github.com/AeonDave/cryptonite-go
- Guides:
- Algorithm Matrix – full specs & references
- Nonce Management – avoid reuse, counters, random generation
- HPKE Usage – hybrid public key encryption
- Post-Quantum – hybrid X25519+ML-KEM guide
- Interoperability – wire formats, encodings, gotchas
- Testing: docs/TESTING.md – KAT, fuzzing, adding test vectors
Contributions welcome! Please:
- Run tests:
go test -race ./... - Check formatting:
go fmt ./...+golangci-lint run - Add vectors: Include KAT for new algorithms (see CONTRIBUTING.md)
- Benchmark:
go test ./test/... -bench=YourFunc -benchmem
See CONTRIBUTING.md for full guidelines.
MIT – see LICENSE
If you find this useful, star the repo! | Questions? Open an issue.