cnfy
A suite of pure Rust libraries implementing Bitcoin's cryptographic stack without external dependencies. Every primitive -- from 256-bit arithmetic to elliptic curve operations -- is built in-house to eliminate supply chain risk.
- No external dependencies -- eliminates supply chain attacks
- No unsafe code -- memory safety without compromise
- No heap allocations -- stack-only, fixed-size arrays
- Algorithm-first optimization -- sparse prime reduction, Lehmer's GCD, scaled comb multiplication
- Struct-per-directory -- every type in its own module, every method in its own file with its own tests
- Constant-time support -- compile-time feature flags enable constant-time implementations
Crates
| Crate | Status | Description |
|---|---|---|
| cnfy-uint | Active | 256-bit modular arithmetic (U256, extended types) |
| cnfy-secp256k1 | Active | secp256k1 elliptic curve operations |
| cnfy-bench | Active | Criterion benchmarks against third-party libraries |
| cnfy-hash | Planned | SHA-256 and RIPEMD-160 hashing |
| cnfy-bs58 | Planned | Base58 encoding and decoding |
| cnfy-btcaddr | Planned | Bitcoin address generation |
Performance
Benchmarks
See cnfy-bench/RESULTS.md for the full benchmark data, including:
- Cross-library comparisons against k256, secp256k1 (C FFI), libsecp256k1, crypto-bigint, ruint, and others
- Constant-time overhead for every operation
- Batch operation scaling (Montgomery's trick)
- Mining loop simulation at various batch sizes
Security
See SECURITY.md for the complete side-channel security reference, including:
- Timing behavior of every algorithm
- Known attack vectors against ECC implementations (CVEs)
- Constant-time alternatives for each operation
- Feature flag mapping (
ct-field,ct-inv,ct-pow,ct-scalar)
Usage
The umbrella crate re-exports sub-crates as cnfy::uint and cnfy::secp256k1:
use U256;
use SecretKey;
// secp256k1 field prime
let p = U256from_be_limbs;
let a = U256from_be_limbs;
let b = U256from_be_limbs;
let product = a.mul_mod;
// Secret key to public key (scaled comb method)
let sk = from_be_bytes.unwrap;
let pk = sk.to_public_key;
let compressed: = pk.serialize;
Testing
Built With
This suite of libraries was built with the accompaniment of Claude Code (Claude Opus 4.6, Max plan).
Links
License
Licensed under the Shariah-Informed Open License (SIOL-1.0).