use crate::u256::U256;
mod extract_top_bits;
mod full_step;
mod inverse;
mod lehmer;
mod new;
mod run;
mod scalar_step;
mod step;
mod toggle_even;
mod top_bits_shift;
mod mul_u256;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct GcdState {
pub modulus: U256,
pub r0: U256,
pub r1: U256,
pub t0: U256,
pub t1: U256,
pub even: bool,
}
#[cfg(test)]
mod ai_tests {
use super::*;
#[test]
fn construct_and_access() {
let state = GcdState {
modulus: U256::from_be_limbs([0, 0, 0, 100]),
r0: U256::from_be_limbs([0, 0, 0, 100]),
r1: U256::from_be_limbs([0, 0, 0, 37]),
t0: U256::ZERO,
t1: U256::ONE,
even: true,
};
assert_eq!(state.modulus, U256::from_be_limbs([0, 0, 0, 100]));
assert_eq!(state.r0, U256::from_be_limbs([0, 0, 0, 100]));
assert_eq!(state.r1, U256::from_be_limbs([0, 0, 0, 37]));
assert_eq!(state.t0, U256::ZERO);
assert_eq!(state.t1, U256::ONE);
assert!(state.even);
}
#[test]
fn copy_semantics() {
let state = GcdState {
modulus: U256::MAX,
r0: U256::MAX,
r1: U256::ONE,
t0: U256::ZERO,
t1: U256::ONE,
even: false,
};
let copy = state;
assert_eq!(state, copy);
}
}