Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

u256_wide_sqr

Computes the square of a u256 value and returns the result as u512 to handle overflow

This function performs wide multiplication to compute a^2 without losing precision, using the identity (a.high * 2^128 + a.low)^2 to handle the full 512-bit result.

Arguments

  • a - The u256 value to square

Returns

  • u512 - The square of the input value as a 512-bit result

Fully qualified path: alexandria_math::mod_arithmetics::u256_wide_sqr

pub fn u256_wide_sqr(a: u256) -> u512