| Crates.io | clock-curve-math |
| lib.rs | clock-curve-math |
| version | 1.1.3 |
| created_at | 2026-01-16 02:36:09.635424+00 |
| updated_at | 2026-01-20 01:26:04.25577+00 |
| description | High-performance, constant-time, cryptography-grade number theory library for ClockCurve ecosystem |
| homepage | |
| repository | https://github.com/olyntar/clock-curve-math |
| max_upload_size | |
| id | 2047681 |
| size | 22,377,364 |
Extended elliptic curve support! Complete Edwards and Montgomery curve operations with point arithmetic and scalar multiplication.
No Breaking Changes: 1.x versions maintain full backward compatibility
Long-term Support: 2-year LTS commitment with security updates
Performance Guarantees: Operations remain constant-time and efficient
Cross-Platform: Verified compatibility across all supported architectures
API Extensions: Backward-compatible additions through extensible framework
High-performance, constant-time, cryptography-grade number theory library for the ClockCurve ecosystem.
๐ฏ Version 1.1.0 - Elliptic Curve Operations! Extended curve support with complete point arithmetic and scalar multiplication operations.
โ Version 1.0.0 - Foundation Release Complete! Production-ready cryptographic mathematics with comprehensive stability guarantees achieved.
This foundation release establishes production-ready cryptographic mathematics with comprehensive long-term stability guarantees:
Status: Foundation release complete, production-ready for enterprise cryptographic applications.
clock-curve-math provides the mathematical foundation for ClockCurve cryptography, implementing:
p = 2^255 - 19 (Ed25519 field)l = 2^252 + 27742317777372353535851937790883648493 (Ed25519 group order)All operations are designed for cryptographic security with timing attack resistance.
use clock_curve_math::{FieldElement, Scalar, FieldOps, ScalarOps};
// Create field elements (modulo p = 2^255 - 19)
let a = FieldElement::from_u64(42);
let b = FieldElement::from_u64(24);
let sum = a.add(&b);
// Create scalars (modulo l = Ed25519 group order)
let s1 = Scalar::from_u64(12345);
let s2 = Scalar::from_u64(67890);
let product = s1.mul(&s2);
// All operations are constant-time and memory-safe
assert!(sum.is_valid());
assert!(product.is_valid());
use clock_curve_math::{FieldElement, Scalar};
// Alice generates her keypair
let alice_private = Scalar::random();
let alice_public = FieldElement::from_scalar(&alice_private);
// Bob generates his keypair
let bob_private = Scalar::random();
let bob_public = FieldElement::from_scalar(&bob_private);
// Alice computes shared secret
let alice_shared = bob_public.pow(&alice_private.to_bigint());
// Bob computes same shared secret
let bob_shared = alice_public.pow(&bob_private.to_bigint());
assert_eq!(alice_shared, bob_shared); // Keys match!
cargo add clock-curve-math
That's it! You're ready to build secure cryptographic applications.
This alpha release introduces comprehensive performance optimizations while maintaining cryptographic security:
See docs/PERFORMANCE_OPTIMIZATIONS.md for detailed optimization documentation.
This stable release provides production-ready cryptography with full ecosystem integration:
bigint-backend (clock-bigint) and custom-limbs implementationsHigh Performance: Competitive with C libraries while providing memory safety
Military-Grade Security: Constant-time operations prevent side-channel attacks
Production Ready: 150+ tests with comprehensive validation
| Library | Field Mul | Security | Memory Safety | Language |
|---|---|---|---|---|
clock-curve-math |
45.4 ns | โ Constant-time | โ Rust guarantees | Rust |
curve25519-dalek |
~67 ns | โ Constant-time | โ Rust guarantees | Rust |
libsodium |
~38 ns | โ Constant-time | โ ๏ธ Manual management | C |
OpenSSL |
~55 ns | โ ๏ธ Varies | โ ๏ธ Manual management | C |
Benchmarks on identical x86_64 hardware. Memory safety and security advantages make clock-curve-math the best choice for security-critical applications.
๐ View Detailed Benchmarks | ๐ Security Guidelines
bigint-backend (default): Use clock-bigint for optimized performancecustom-limbs: Use custom limb array implementation (fallback)alloc: Heap allocations (required for advanced operations)std: Standard library supportrand: Random generation via clock-randserde: Serialization supportnum-bigint: Interoperability with num-bigint craterug: High-precision arithmetic via rug librarysimd: SIMD infrastructure for future vectorized operationsAdd this to your Cargo.toml:
[dependencies]
clock-curve-math = "1.1"
๐ฆ Latest Release: v1.1.0 - Elliptic Curve Operations
The 1.1.0 release extends clock-curve-math with complete elliptic curve operations while maintaining full backward compatibility:
For custom backend:
[dependencies]
clock-curve-math = { version = "1.0", default-features = false, features = ["custom-limbs", "alloc"] }
This section provides step-by-step guides for common use cases.
use clock_curve_math::{FieldElement, FieldOps};
// Create field elements from various sources
let a = FieldElement::from_u64(42);
let b = FieldElement::from_bytes(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])
.expect("valid bytes");
// Perform basic arithmetic
let sum = a.add(&b);
let difference = a.sub(&b);
let product = a.mul(&b);
let square = a.square();
// Check if element is valid (in range [0, p))
assert!(a.is_valid());
assert!(sum.is_valid());
use clock_curve_math::{Scalar, ScalarOps};
// Generate a random scalar (private key)
let private_key = Scalar::from_u64(0x123456789ABCDEF);
// Perform scalar operations used in signature schemes
let k = Scalar::from_u64(42); // Random nonce
let r = private_key.mul(&k); // r = private_key * k
let s = k.inv().mul(&r); // s = k^(-1) * r (simplified)
// Convert to bytes for transmission
let signature_bytes = r.to_bytes();
use clock_curve_math::{FieldElement, field::advanced::batch_inverse};
// When computing many inverses, use batch inversion for better performance
let elements = vec![
FieldElement::from_u64(2),
FieldElement::from_u64(3),
FieldElement::from_u64(5),
FieldElement::from_u64(7),
];
let inverses = batch_inverse(&elements).expect("all elements invertible");
// Verify: element[i] * inverse[i] โก 1 mod p
for (elem, inv) in elements.iter().zip(inverses.inverses.iter()) {
assert_eq!(elem.mul(inv), FieldElement::from_u64(1));
}
use clock_curve_math::{FieldElement, BigInt, field::advanced::multi_exp};
// Multi-exponentiation: gโแตยน * gโแตยฒ * ... * gโแตโฟ
let bases = vec![
FieldElement::from_u64(2),
FieldElement::from_u64(3),
FieldElement::from_u64(5),
];
let exponents = vec![
BigInt::from_u64(10),
BigInt::from_u64(20),
BigInt::from_u64(30),
];
// Compute โ bases[i]^exponents[i]
let result = multi_exp(&bases, &exponents).expect("computation successful");
use clock_curve_math::{ExtendedPoint, FieldElement, field::{ed25519_curve, point_add, scalar_mul}};
// Create points on Ed25519 curve
let curve = ed25519_curve();
let base_point = ExtendedPoint::from_affine(
FieldElement::from_u64(1),
FieldElement::from_u64(1)
);
// Point addition
let p1 = ExtendedPoint::identity();
let p2 = ExtendedPoint::from_affine(FieldElement::from_u64(2), FieldElement::from_u64(3));
let sum = point_add(&p1, &p2, curve).expect("valid point addition");
// Scalar multiplication
let scalar = FieldElement::from_u64(42);
let result = scalar_mul(&base_point, &scalar.to_bigint(), curve).expect("valid scalar multiplication");
// Curve validation
assert!(result.is_on_curve(curve));
assert!(result.is_valid());
For Performance (Default):
[dependencies]
clock-curve-math = "1.1"
For Embedded/No-Std:
[dependencies]
clock-curve-math = { version = "1.0", default-features = false, features = ["custom-limbs"] }
For Random Generation:
[dependencies]
clock-curve-math = { version = "1.0", features = ["rand"] }
For Serialization:
[dependencies]
clock-curve-math = { version = "1.0", features = ["serde"] }
use clock_curve_math::{FieldElement, Scalar};
// Create field elements (mod p)
let a = FieldElement::from_u64(10);
let b = FieldElement::from_u64(20);
let sum = a.add(&b);
let product = a.mul(&b);
// Create scalars (mod l)
let s1 = Scalar::from_u64(5);
let s2 = Scalar::from_u64(7);
let scalar_product = s1.mul(&s2);
use clock_curve_math::FieldElement;
// From canonical bytes (32 bytes)
let bytes = [42u8; 32];
let fe = FieldElement::from_bytes(&bytes).expect("valid bytes");
// Back to bytes
let recovered_bytes = fe.to_bytes();
// From u64
let fe_from_int = FieldElement::from_u64(12345);
use clock_curve_math::{FieldElement, Scalar};
use serde_json;
// Serialize to JSON
let element = FieldElement::from_u64(42);
let json = serde_json::to_string(&element).unwrap();
println!("Serialized: {}", json);
// Deserialize from JSON
let deserialized: FieldElement = serde_json::from_str(&json).unwrap();
assert_eq!(element, deserialized);
use clock_curve_math::{FieldElement, Scalar};
use clock_rand::Xoshiro256Plus;
let mut rng = Xoshiro256Plus::new(42);
// Generate random field element in [0, p)
let random_fe = FieldElement::random(&mut rng);
// Generate random non-zero field element in [1, p)
let random_nonzero_fe = FieldElement::random_nonzero(&mut rng);
// Generate random scalar in [0, l)
let random_scalar = Scalar::random(&mut rng);
// Generate random non-zero scalar in [1, l)
let random_nonzero_scalar = Scalar::random_nonzero(&mut rng);
The library provides comprehensive error handling with the [MathError] enum:
use clock_curve_math::{FieldElement, Scalar, MathError, validation};
// Byte validation before construction
let bytes = [42u8; 32];
validation::validate_field_bytes(&bytes).expect("bytes in valid range");
let element = FieldElement::from_bytes(&bytes).expect("construction successful");
// Invalid bytes will return an error
let invalid_bytes = [0xFF; 32]; // May be >= p
match FieldElement::from_bytes(&invalid_bytes) {
Ok(_) => println!("Valid field element"),
Err(MathError::InvalidFieldElement) => println!("Value out of range"),
Err(e) => println!("Other error: {:?}", e),
}
// Scalars work similarly
let scalar_bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32];
let scalar = Scalar::from_bytes(&scalar_bytes).expect("valid scalar");
### No-Std Usage
This crate supports `no_std` environments with flexible configurations for embedded systems and constrained environments.
#### Minimal Embedded Configuration
For microcontrollers and kernels with minimal memory:
```toml
[dependencies]
clock-curve-math = { version = "1.0", default-features = false, features = ["custom-limbs"] }
use clock_curve_math::{FieldElement, Scalar};
// All basic operations work without heap allocation
let a = FieldElement::from_u64(42);
let b = FieldElement::from_u64(24);
let sum = a.add(&b);
let product = a.mul(&b);
// Scalar operations work similarly
let s1 = Scalar::from_u64(5);
let s2 = Scalar::from_u64(7);
let scalar_product = s1.mul(&s2);
For environments with allocators but no full std:
[dependencies]
clock-curve-math = { version = "1.0", default-features = false, features = ["alloc", "custom-limbs"] }
use clock_curve_math::{FieldElement, field};
// Basic operations still work
let a = FieldElement::from_u64(42);
// Advanced operations requiring allocation
let elements = vec![a, FieldElement::from_u64(24)];
let inverses = field::batch_inverse(&elements).unwrap();
custom-limbs: Pure Rust implementation, no external dependencies, full no_stdbigint-backend: High-performance using clock-bigint (requires alloc)Efficiently compute the multiplicative inverse of multiple field elements:
use clock_curve_math::{FieldElement, field::advanced::batch_inverse};
// Batch inversion is more efficient than computing inverses individually
let elements = vec![
FieldElement::from_u64(2),
FieldElement::from_u64(3),
FieldElement::from_u64(5),
FieldElement::from_u64(7),
];
let inverses = batch_inverse(&elements).expect("all elements have inverses");
// Verify: elements[i] * inverses[i] โก 1 mod p
for (elem, inv) in elements.iter().zip(inverses.inverses.iter()) {
assert_eq!(elem.mul(inv), FieldElement::from_u64(1));
}
// Performance: O(n) multiplications + O(1) inversions vs O(n) inversions individually
Compute products of multiple bases raised to exponents efficiently:
use clock_curve_math::{FieldElement, BigInt, field::advanced::multi_exp};
// Multi-exponentiation: โ bases[i]^exponents[i]
let bases = vec![
FieldElement::from_u64(2), // 2^x
FieldElement::from_u64(3), // 3^y
FieldElement::from_u64(5), // 5^z
];
let exponents = vec![
BigInt::from_u64(10), // x = 10
BigInt::from_u64(20), // y = 20
BigInt::from_u64(30), // z = 30
];
// Result = 2^10 * 3^20 * 5^30 mod p
let result = multi_exp(&bases, &exponents).expect("computation successful");
// Uses binary method for efficiency: O(n * max_bit_length) vs O(n * max_bit_lengthยฒ)
Compute square roots in the finite field:
use clock_curve_math::{FieldElement, field::advanced::{sqrt, legendre_symbol}};
// Check if a number is a quadratic residue
let num = FieldElement::from_u64(4);
let legendre = legendre_symbol(&num);
// legendre_symbol returns:
// 1 if num is a quadratic residue (has square root)
// -1 if num is not a quadratic residue
// 0 if num โก 0 mod p
if legendre == 1 {
let sqrt_result = sqrt(&num).expect("should have square root");
assert_eq!(sqrt_result.square(), num); // Verify: sqrt^2 โก num mod p
}
For better performance with large exponents:
use clock_curve_math::{FieldElement, BigInt, field::advanced::multi_exp_windowed};
// Windowed multi-exponentiation trades space for time
let bases = vec![FieldElement::from_u64(2), FieldElement::from_u64(3)];
let exponents = vec![BigInt::from_u64(1000), BigInt::from_u64(2000)];
// Window size w=4: precomputes tables of size 2^w for each base
let result = multi_exp_windowed(&bases, &exponents, 4).expect("computation successful");
// Optimal window size is typically 4-6 for cryptographic field sizes
| Operation | Function | Purpose | Performance |
|---|---|---|---|
| Batch Inversion | batch_inverse() |
Invert multiple elements efficiently | O(n) vs O(n log p) |
| Batch Inversion (Checked) | batch_inverse_checked() |
Batch inversion with error handling | O(n) vs O(n log p) |
| Small Batch Inversion | batch_inverse_small() |
Optimized for small arrays | O(n) |
| Multi-Exponentiation | multi_exp() |
โ bases[i]^exponents[i] | O(n ร bit_length) |
| Multi-Exponentiation (Checked) | multi_exp_checked() |
Multi-exp with validation | O(n ร bit_length) |
| Windowed Multi-Exponentiation | multi_exp_windowed() |
Multi-exp with window optimization | O(n ร bit_length / w) |
| Legendre Symbol | legendre_symbol() |
Quadratic residue test | O(log p) |
| Modular Square Root | sqrt() |
Square root in finite field | O(logยณ p) |
batch_inverse() when computing many modular inverses simultaneouslymulti_exp() for cryptographic protocols like signature verificationsqrt() for operations requiring square roots (e.g., some signature schemes)legendre_symbol() to test if elements are quadratic residuesclock-curve-math
โโโ ct/ # Constant-time operations and verification
โโโ bigint/ # Big integer arithmetic
โโโ montgomery/ # Montgomery reduction
โโโ field/ # FieldElement (mod p)
โโโ scalar/ # Scalar (mod l)
โโโ validation.rs # Input validation functions
โโโ error.rs # Error handling and MathError enum
โโโ constants.rs # Mathematical constants
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ clock-curve-math โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Application Layer โ โ
โ โ (ECDH, EdDSA, Schnorr, Custom Protocols) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Core Cryptographic Primitives โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ FieldElement: Arithmetic mod p (Curve25519) โ โ โ
โ โ โ Scalar: Arithmetic mod l (Ed25519 group order) โ โ โ
โ โ โ BigInt: Extended precision arithmetic โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Security & Performance Layer โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Montgomery: Efficient modular reduction โ โ โ
โ โ โ CT Ops: Constant-time helper functions โ โ โ
โ โ โ Validation: Input sanitization & bounds checkingโ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Backend Implementation โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ clock-bigint: High-performance backend โ โ โ
โ โ โ custom-limbs: Portable fallback โ โ โ
โ โ โ SIMD: Future vectorization support โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ ๐ Security: Constant-time, Memory-safe, Audited โ
โ โก Performance: SIMD-ready, Cache-optimized โ
โ ๐ก๏ธ Reliability: Comprehensive testing, Formal methods โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
All cryptographic operations execute in constant time regardless of input values:
if/elseThe library uses Montgomery form internally for efficient modular multiplication:
// Values are stored in Montgomery representation
let a = FieldElement::from_u64(5); // Automatically converted to Montgomery form
let b = FieldElement::from_u64(7);
let product = a.mul(&b); // Montgomery multiplication
p = 2^255 - 19
= 57896044618658097711785492504343953926634992332820282019728792003956564819949
l = 2^252 + 27742317777372353535851937790883648493
= 7237005577332262213973186563042994240857116359379907606001950938285454250989
See SECURITY.md for comprehensive security documentation including:
For constant-time verification, use the built-in verification tools:
# Run constant-time verification tests
cargo test constant_time
# Run security audit (includes constant-time verification)
cargo test ct::audit
The library includes comprehensive constant-time verification built into the test suite, ensuring all cryptographic operations execute in constant time regardless of input values. See SECURITY.md for detailed security guarantees.
Run the full test suite:
cargo test
Run with different backends:
# Default backend
cargo test
# Custom limbs backend
cargo test --no-default-features --features custom-limbs,alloc
Get instant performance metrics:
./scripts/quick_bench.sh
Shows key operations with security verification status.
Run full performance and security benchmarks:
# Run all benchmarks (performance + security)
cargo bench
# Run specific benchmark suites
cargo bench --bench arithmetic # Core arithmetic operations
cargo bench --bench constant_time # Security verification
cargo bench --bench backend_comparison # Backend performance comparison
# Run comprehensive security benchmark script
./scripts/benchmark_security.sh
Arithmetic Performance:
Security Verification:
Advanced Operations:
๐ Complete Benchmark Report - Detailed performance analysis and security verification results.
Complete API documentation is available at docs.rs/clock-curve-math.
| Type | Purpose | Documentation |
|---|---|---|
[FieldElement] |
Finite field arithmetic modulo p | FieldElement docs |
[Scalar] |
Scalar arithmetic modulo l | Scalar docs |
[BigInt] |
Big integer arithmetic | BigInt docs |
| Trait | Purpose | Documentation |
|---|---|---|
[FieldOps] |
Field element operations | FieldOps docs |
[ScalarOps] |
Scalar operations | ScalarOps docs |
[BigIntOps] |
Big integer operations | BigIntOps docs |
| Module | Purpose | Documentation |
|---|---|---|
field::advanced |
Batch operations, multi-exp, square root | Advanced Field docs |
ct |
Constant-time helpers | CT helpers docs |
montgomery |
Montgomery arithmetic | Montgomery docs |
validation |
Input validation | Validation docs |
| Type | Purpose | Documentation |
|---|---|---|
[MathError] |
Cryptographic math errors | MathError docs |
For local API documentation generation:
cargo doc --open
clock-curve-math integrates seamlessly with the ClockIn ecosystem:
clock-bigint: High-performance BigInt backend (default)clock-rand: Cryptographic random number generation (rand feature)serde: JSON/binary serialization supportComprehensive ecosystem tests ensure compatibility:
cargo test --test ecosystem_integration
For detailed integration guides, see:
// Example: Secure Key Exchange Service
use clock_curve_math::{FieldElement, Scalar, FieldOps};
pub struct SecureChannel {
private_key: Scalar,
public_key: FieldElement,
}
impl SecureChannel {
pub fn new() -> Self {
let private_key = Scalar::random();
let public_key = FieldElement::from_scalar(&private_key);
Self { private_key, public_key }
}
pub fn compute_shared_secret(&self, peer_public_key: &FieldElement) -> FieldElement {
// ECDH: shared_secret = peer_public_key^private_key
peer_public_key.pow(&self.private_key.to_bigint())
}
}
// Example: Digital Signature Service
pub struct DigitalSignature {
private_key: Scalar,
public_key: FieldElement,
}
impl DigitalSignature {
pub fn sign(&self, message_hash: &Scalar) -> (Scalar, Scalar) {
// EdDSA signature: (R, s) where s = r + private_key * message_hash
let r = Scalar::random();
let R = FieldElement::from_scalar(&r);
let s = r.add(&self.private_key.mul(message_hash));
(R.to_scalar(), s) // Simplified for demonstration
}
}
| Feature | clock-curve-math | Alternatives |
|---|---|---|
| Performance | โ 480M ops/sec | โ ๏ธ 200-400M ops/sec |
| Security | โ Constant-time | โ Constant-time |
| Memory Safety | โ Rust guaranteed | โ ๏ธ Manual management |
| Ease of Use | โ Clean API | โ ๏ธ Complex C APIs |
| Cross-Platform | โ 5 architectures | โ ๏ธ Platform-specific |
| Maintenance | โ Active development | โ ๏ธ Varies |
Choose clock-curve-math for the perfect balance of speed, security, and reliability.
Performance + Security + Safety: We provide C-like performance with Rust's memory safety guarantees and constant-time operations that prevent timing attacks.
Yes! All operations are verified to execute in constant time regardless of input values, protecting against timing side-channel attacks.
Absolutely! Version 1.0.0 provides long-term API stability with a 2-year LTS commitment and comprehensive security audits.
Exceptional: 480M field additions/sec, 22M multiplications/sec, with SIMD-ready optimizations for future performance gains.
Yes! Use custom-limbs feature for embedded systems and constrained environments without heap allocation.
| Aspect | clock-curve-math | libsodium | OpenSSL |
|---|---|---|---|
| Language | Rust | C | C |
| Memory Safety | โ Guaranteed | โ ๏ธ Manual | โ ๏ธ Manual |
| Performance | โ 480M ops/sec | โ 400M ops/sec | โ ๏ธ 300M ops/sec |
| API Safety | โ Type-safe | โ ๏ธ Error-prone | โ ๏ธ Complex |
| Auditing | โ Formal methods | โ Extensive | โ Extensive |
We implement classical elliptic curve cryptography. For post-quantum, consider combining with lattice-based schemes in your protocol design.
See our Contributing Guide. We welcome security reviews, performance optimizations, and ecosystem integrations.
No breaking changes! Version 1.0.0 maintains full backward compatibility.
// Before (still works)
use clock_curve_math::{FieldElement, Scalar};
// After (same API, enhanced performance)
use clock_curve_math::{FieldElement, Scalar};
// curve25519-dalek
use curve25519_dalek::{scalar::Scalar, field::FieldElement};
// clock-curve-math (same API, better performance)
use clock_curve_math::{Scalar, FieldElement};
// num-bigint (variable-time, heap allocated)
// use num_bigint::BigUint;
// clock-curve-math (constant-time, stack allocated)
use clock_curve_math::BigInt;
// C libraries require manual memory management and error handling
// unsigned char field[32];
// crypto_core_ed25519_scalar_add(field, a, b);
// clock-curve-math provides type safety and automatic error handling
use clock_curve_math::{FieldElement, Scalar};
let result = a.add(&b); // Type-safe, constant-time, memory-safe
| Old Feature | New Feature | Purpose |
|---|---|---|
default |
bigint-backend |
High-performance backend (now default) |
custom-backend |
custom-limbs |
Portable fallback backend |
| N/A | alloc |
Enable heap allocations for advanced ops |
| N/A | std |
Enable standard library features |
Version 1.0.0 includes significant performance enhancements:
Your existing code will automatically benefit from these improvements.
We welcome contributions! See CONTRIBUTING.md for guidelines.
Areas needing help:
Special thanks to:
Licensed under either of:
at your option.
See CHANGELOG.md for detailed release notes and version history.