avila-primitives
Primitive types and core abstractions for the Avila ecosystem.
Features
Features
- Zero Dependencies - Pure Rust, no external crates
- Stack-First - Fixed-size types allocated on stack
- const fn - Maximum compile-time computation
- no_std Compatible - Works in embedded environments
- Constant-Time Ops - Security-critical operations
Types
Fixed-Size Integers
U64,U128- Type aliases for consistencyU256- 256-bit integer (4 × u64 limbs)U512- 512-bit integer (8 × u64 limbs)U1024,U2048,U4096- Larger types (array of limbs)
Byte Arrays
Bytes32- 32-byte array (256 bits)Bytes64- 64-byte array (512 bits)
Traits
BitOps- Bit manipulationCountBits- Type metadataFromBytes/ToBytes- ConversionsByteArray- Byte array operations
Examples
Basic Usage
use *;
// Create U256 from u64
let a = U256from_u64;
let b = U256from_u64;
// Arithmetic
let sum = a + b;
assert_eq!;
// Checked operations
let overflow = U256MAX.checked_add;
assert!;
Byte Operations
use ;
let mut data = ZERO;
data.0 = 0xFF;
// Zeroize (security)
data.zeroize;
assert_eq!;
Constant-Time Operations
use ;
// Constant-time selection (no branches)
let secret = ct_select_u64;
// Constant-time comparison
assert!;
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
For no_std environments:
[]
= { = "0.1.0", = false }
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Contribution
Contributions are welcome! Please see CONTRIBUTING.md.