miden_precompiles/math/u256.rs
1//! U256 wrapping arithmetic domain for the uint precompile.
2
3use miden_core::{Felt, ZERO};
4
5use crate::math::uint::{Limbs, UintSpec};
6
7/// Marker for arithmetic modulo `2^256`.
8#[derive(Debug, Default, Clone, Copy)]
9pub struct U256;
10
11impl U256 {
12 /// Stable local domain selector carried in uint precompile tags.
13 pub const ID: Felt = ZERO;
14
15 /// Encoded modulus sentinel for arithmetic modulo `2^256`.
16 pub const ENCODED_MODULUS: Limbs = [0; 8];
17
18 /// Maximum canonical U256 value, `2^256 - 1`.
19 pub const MAX: Limbs = [u32::MAX; 8];
20}
21
22impl UintSpec for U256 {
23 const ID: Felt = Self::ID;
24 const ENCODED_MODULUS: Limbs = Self::ENCODED_MODULUS;
25}