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	divisible::{Divisible, impl_divisible_self},
7	underlier::ScaledUnderlier,
8};
9
10pub type M256 = ScaledUnderlier<M128, 2>;
11
12// Reflexive `Divisible<Self>`, needed by the width-one `PackedPrimitiveType<M256, _>` packing whose
13// scalar (e.g. `GhashSq256b`) is itself `M256`-backed. `M256` is a `ScaledUnderlier` alias here, so
14// this is the portable/aarch64 counterpart to the native `impl_divisible_self!(M256)` on x86_64.
15impl_divisible_self!(M256);
16
17pub const fn m256_from_u128s(lo: u128, hi: u128) -> M256 {
18	ScaledUnderlier([M128::from_u128(lo), M128::from_u128(hi)])
19}