Skip to main content

binius_field/arch/portable/
m256.rs

1// Copyright 2023-2025 Irreducible Inc.
2// Copyright 2026 The Binius Developers
3
4use crate::{
5	arch::M128,
6	underlier::{Divisible, ScaledUnderlier, impl_divisible_self},
7};
8
9pub type M256 = ScaledUnderlier<M128, 2>;
10
11// Reflexive `Divisible<Self>`, needed by the width-one `PackedPrimitiveType<M256, _>` packing whose
12// scalar (e.g. `GhashSq256b`) is itself `M256`-backed. `M256` is a `ScaledUnderlier` alias here, so
13// this is the portable/aarch64 counterpart to the native `impl_divisible_self!(M256)` on x86_64.
14impl_divisible_self!(M256);
15
16pub const fn m256_from_u128s(lo: u128, hi: u128) -> M256 {
17	ScaledUnderlier([M128::from_u128(lo), M128::from_u128(hi)])
18}