cryptonite-0.8: Cryptography Primitives sink

LicenseBSD-style
MaintainerDanny Navarro <j@dannynavarro.net>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

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

Documentation

type BinaryPolynomial = Integer Source

Binary Polynomial represented by an integer

addF2m :: Integer -> Integer -> Integer Source

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

mulF2m Source

Arguments

:: BinaryPolynomial

Irreducible binary polynomial

-> Integer 
-> Integer 
-> Integer 

Multiplication over F₂m.

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

squareF2m Source

Arguments

:: BinaryPolynomial

Irreducible binary polynomial

-> Integer 
-> Integer 

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

modF2m Source

Arguments

:: BinaryPolynomial

Irreducible binary polynomial

-> Integer 
-> Integer 

Binary polynomial reduction modulo using long division algorithm.

invF2m Source

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 Source

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