Avila Nucleus
Low-level cryptographic primitives and bit-manipulation operations
Overview
avila-nucleus provides foundational building blocks for cryptographic operations, including constant-time comparisons, bit manipulation, SIMD operations, and mathematical primitives used throughout the Avila ecosystem.
Features
- Constant-Time Operations: Timing-attack resistant comparisons and operations
- Bit Manipulation: Efficient bit-level operations for 256-bit, 512-bit, and larger integers
- SIMD Support: Hardware-accelerated operations for x86_64 architectures
- Arithmetic Primitives: Addition, subtraction, multiplication, division for big integers
- Modular Arithmetic: Montgomery multiplication and reduction
- Endianness Conversions: Little-endian byte array operations
Modules
bits
Low-level bit manipulation and arithmetic operations:
u256_ops: 256-bit unsigned integer operationsu512_ops: 512-bit unsigned integer operationsu1024_ops: 1024-bit unsigned integer operationsu2048_ops: 2048-bit unsigned integer operationsu4096_ops: 4096-bit unsigned integer operations
simd
SIMD-accelerated operations (x86_64):
- Parallel processing for cryptographic operations
- Hardware acceleration when available
Core Operations
Constant-Time Equality
use eq256;
let a = ;
let b = ;
assert!;
Big Integer Arithmetic
use *;
let a = ;
let b = ;
let = add256;
assert_eq!;
Division with Remainder
use *;
let dividend = ;
let divisor = ;
let = div256;
assert_eq!;
assert_eq!;
Security Considerations
All operations in this crate are designed with security in mind:
- Constant-time operations prevent timing attacks
- No branching on secret data
- Careful carry propagation in arithmetic operations
- Secure memory handling for sensitive data
Performance
The crate is optimized for:
- Zero-cost abstractions
- Minimal allocations (mostly stack-based)
- Cache-friendly memory access patterns
- SIMD acceleration where available
Testing
Run the test suite:
Current test coverage: 47 tests passing
Dependencies
coreonly (no_std compatible)- Optional SIMD support requires x86_64 architecture
License
Part of the Avila cryptographic suite.
Related Crates
avila-primitives: High-level big integer types using these primitivesavila-crypto: Cryptographic algorithms built on these foundationsavila-atom: Thread-safe atomic operations
Contributing
When adding new operations:
- Ensure constant-time behavior for security-sensitive code
- Add comprehensive tests including edge cases
- Document security properties and performance characteristics
- Maintain no_std compatibility