| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Word.Wide
Description
Wide words, consisting of two Limbs.
Synopsis
- data Wide = Wide !Limb2
- wide :: Word -> Word -> Wide
- to_vartime :: Integer -> Wide
- from_vartime :: Wide -> Integer
- select :: Wide -> Wide -> Choice -> Wide
- or :: Wide -> Wide -> Wide
- and :: Wide -> Wide -> Wide
- xor :: Wide -> Wide -> Wide
- not :: Wide -> Wide
- eq :: Wide -> Wide -> Choice
- eq_vartime :: Wide -> Wide -> Bool
- add :: Wide -> Wide -> Wide
- add_o :: Wide -> Wide -> (Wide, Word)
- sub :: Wide -> Wide -> Wide
- mul :: Wide -> Wide -> Wide
- neg :: Wide -> Wide
- add_o# :: Limb2 -> Limb2 -> (# Limb2, Limb #)
- add_w# :: Limb2 -> Limb2 -> Limb2
- sub_b# :: Limb2 -> Limb2 -> (# Limb2, Limb #)
- sub_w# :: Limb2 -> Limb2 -> Limb2
- mul_w# :: Limb2 -> Limb2 -> Limb2
Wide Words
Little-endian wide words.
Constructors
| Wide !Limb2 |
Construction, Conversion
to_vartime :: Integer -> Wide Source #
from_vartime :: Wide -> Integer Source #
Constant-time selection
Return a if c is truthy, otherwise return b.
>>>import qualified Data.Choice as C>>>select 0 1 (C.true# ())1
Bit Manipulation
Comparison
eq :: Wide -> Wide -> Choice Source #
Compare Wide words for equality in constant time.
>>>import qualified Data.Chocie as C>>>C.decide (eq 1 1)True
eq_vartime :: Wide -> Wide -> Bool Source #
Compare Wide words for equality in variable time.
>>>eq_vartime 1 1True
Arithmetic
Overflowing addition on Wide words, computing 'a + b', returning
the sum and carry bit.
Wrapping negation on Wide words, producing an additive inverse.
>>>neg 1340282366920938463463374607431768211455>>>1 + neg 1>>>0
Unboxed Arithmetic
Arguments
| :: Limb2 | augend |
| -> Limb2 | addend |
| -> (# Limb2, Limb #) | (# sum, carry bit #) |
Overflowing addition, computing 'a + b', returning the sum and a carry bit.
Arguments
| :: Limb2 | augend |
| -> Limb2 | addend |
| -> Limb2 | sum |
Wrapping addition, computing 'a + b'.
Arguments
| :: Limb2 | minuend |
| -> Limb2 | subtrahend |
| -> (# Limb2, Limb #) | (# difference, borrow mask #) |
Borrowing subtraction, computing 'a - b' and returning the difference with a borrow mask.
Arguments
| :: Limb2 | minuend |
| -> Limb2 | subtrahend |
| -> Limb2 | difference |
Wrapping subtraction, computing 'a - b'.