Crypto.Number.F2m

crypto-numbers-0.2.7: Cryptographic numbers: functions and algorithms

License | BSD-style
Maintainer | Danny Navarro <j@dannynavarro.net>
Stability | experimental
Portability | Good
Safe Haskell | None
Language | Haskell98

Crypto.Number.F2m

Description

This module provides basic arithmetic operations over F₂m. Performance is not optimal and it doesn't provide protection against timing attacks. The `m` parameter is implicitly derived from the irreducible polynomial where applicable.

Synopsis

- addF2m :: Integer -> Integer -> Integer
- mulF2m :: BinaryPolynomial -> Integer -> Integer -> Integer
- squareF2m :: BinaryPolynomial -> Integer -> Integer
- modF2m :: Integer -> Integer -> Integer
- invF2m :: BinaryPolynomial -> Integer -> Maybe Integer
- divF2m :: BinaryPolynomial -> Integer -> Integer -> Maybe Integer

# Documentation

addF2m :: Integer -> Integer -> Integer #

Addition over F₂m. This is just a synonym of `xor`.

mulF2m #

Arguments

:: BinaryPolynomial | Irreducible binary polynomial
-> Integer |
-> Integer |
-> Integer |

Multiplication over F₂m.

n1 * n2 (in F(2^m))

squareF2m #

Arguments

:: BinaryPolynomial | Irreducible binary polynomial
-> Integer |
-> Integer |

Squaring over F₂m. TODO: This is still slower than `mulF2m`.

modF2m #

Arguments

:: Integer | Irreducible binary polynomial
-> Integer |
-> Integer |

Binary polynomial reduction modulo using long division algorithm.

invF2m #

Arguments

:: BinaryPolynomial | Irreducible binary polynomial
-> Integer |
-> Maybe Integer |

Inversion of @n over F₂m using extended Euclidean algorithm.

If @n doesn't have an inverse, Nothing is returned.

divF2m #

Arguments

:: BinaryPolynomial | Irreducible binary polynomial
-> Integer | Dividend
-> Integer | Quotient
-> Maybe Integer |

Division over F₂m. If the dividend doesn't have an inverse it returns `Nothing`.

Compute n1 / n2