# brik64-core
[](https://crates.io/crates/brik64-core)
[](https://docs.rs/brik64-core)
[](LICENSE)
[](https://brik64.dev)
BRIK-64 Core Monomers for Rust — **Digital Circuitality** natively in Rust.
64 formally verified atomic operations + EVA algebra composition operators.
All functions are total, deterministic, and free of undefined behavior.
## Installation
```toml
[dependencies]
brik64-core = "2.0"
# With SHA-256 support:
brik64-core = { version = "2.0", features = ["sha2"] }
```
## Usage
```rust
use brik64_core::{mc, eva};
// Direct monomer use
let sum = mc::add8(200u8, 100u8); // saturating: 255
let (q, r) = mc::div8(17u8, 5u8); // (3, 2) — division by zero safe
let s = mc::concat("hello", " world"); // "hello world"
// EVA sequential composition ⊗
let pipeline = eva::seq(
|x: (u8, u8)| mc::add8(x.0, x.1),
|sum| mc::mod8(sum, 10),
);
let result = pipeline((7u8, 8u8)); // add8(7,8)=15 → mod8(15,10)=5
assert_eq!(result, 5);
// EVA parallel composition ∥
let dual = eva::par(mc::add8, mc::xor8);
let (a, b) = dual((10u8, 5u8), (0b1100u8, 0b1010u8));
assert_eq!(a, 15);
assert_eq!(b, 0b0110);
// EVA conditional composition ⊕
let transform = eva::cond(
|x: &i64| *x % 2 == 0,
|x| x * 2,
|x| x / 2,
);
assert_eq!(transform(4i64), 8);
assert_eq!(transform(5i64), 2);
```
## Monomer Families
| Arithmetic | MC_00–07 | `add8`, `sub8`, `mul8`, `div8`, `mod8`, `abs64`, `neg64`, `clamp` |
| Logic | MC_08–15 | `and8`, `or8`, `xor8`, `not8`, `shl8`, `shr8`, `bool_and`, `bool_or` |
| Memory | MC_16–23 | `load`, `store`, `push`, `pop`, `peek`, `alloc`, `free`, `len_mem` |
| Control | MC_24–31 | `mc_if`, `mc_loop`, `nop`, `halt`, `cmp_eq`, `cmp_lt`, `cmp_gt`, `mc_call` |
| I/O | MC_32–39 | `read_file`, `write_file`, `append_file`, `read_str`, `write_stdout`, `write_stderr`, `file_exists`, `file_size` |
| String | MC_40–47 | `concat`, `substr`, `trim`, `len`, `contains`, `starts_with`, `ends_with`, `char_at` |
| Crypto | MC_48–55 | `hash_sha256`\*, `hash_hex`\*, `xor_bytes`, `rotate_left`, `rotate_right`, `constant_eq`, `zero_bytes`, `bytes_to_hex` |
| System | MC_56–63 | `time_unix`, `time_ms`, `env_get`, `env_set`, `pid`, `args`, `exit_code`, `sleep_ms` |
\* Requires `features = ["sha2"]`
## EVA Algebra
| `⊗` | `eva::seq` | Sequential: `B(A(x))` |
| `∥` | `eva::par` | Parallel: `(A(x), B(y))` |
| `⊕` | `eva::cond` | Conditional: `if pred { A(x) } else { B(x) }` |
Any function composed exclusively from Core monomers via EVA operators
retains its `Φ_c = 1` guarantee — the circuit is closed.
## Digital Circuitality
- [brik64.dev](https://brik64.dev)
- [docs.brik64.dev](https://docs.brik64.dev)
- [github.com/brik64](https://github.com/brik64)
## License
Apache-2.0 — © 2026 BRIK-64 Inc.