Safe Haskell | None |
---|---|
Language | Haskell2010 |
Small Galois fields via precomputed tables of Zech's logarithms.
https://en.wikipedia.org/wiki/Zech%27s_logarithm
When "creating" a field, we precompute the Zech logarithm table. After that, computations should be fast.
This is practical up to fields of size 10^5
-10^6
.
This representation also supports handling of subfields.
Synopsis
- data ZechTable = ZechTable {
- _zechParams :: !(Int32, Int32)
- _qMinus1 :: !Int32
- _logMinus1 :: !Int32
- _embedding :: !(Vector Int32)
- _zechLogs :: !(Vector Int32)
- makeZechTable :: forall p m. WitnessGF p m -> ZechTable
- newtype WitnessZech (p :: Nat) (m :: Nat) = WitnessZech {}
- data SomeWitnessZech = forall p m. SomeWitnessZech (WitnessZech p m)
- mkZechField :: Int -> Int -> Maybe SomeWitnessZech
- unsafeZechField :: Int -> Int -> SomeWitnessZech
- constructZechField :: SNat64 p -> SNat64 m -> Maybe (WitnessZech p m)
- data Zech (p :: Nat) (m :: Nat)
- data SubField (p :: Nat) (m :: Nat) (k :: Nat)
- ambientWitness :: SubField p m k -> WitnessZech p m
- subFieldWitness :: SubField p m k -> WitnessZech p k
- subFieldProof :: SubField p m k -> Divides k m
- fiberSize :: SubField p m k -> Int32
- subFieldName :: SubField p m k -> String
- data SomeSubField (p :: Nat) (m :: Nat) = forall k. SomeSubField (SubField p m k)
- constructSubField :: WitnessZech p m -> Divides k m -> SubField p m k
- enumerateSubFields :: forall p m. WitnessZech p m -> [SomeSubField p m]
- embedSubField :: SubField p m k -> Zech p k -> Zech p m
- projectSubField :: SubField p m k -> Zech p m -> Maybe (Zech p k)
- isInSubField :: SubField p m k -> Zech p m -> Bool
Tables of Zech logarithms
A table of Zech logarithms (and some more data required for the operations)
ZechTable | |
|
makeZechTable :: forall p m. WitnessGF p m -> ZechTable Source #
Witness for the existence of the field
newtype WitnessZech (p :: Nat) (m :: Nat) Source #
Instances
Show (WitnessZech p m) Source # | |
Defined in Math.FiniteField.GaloisField.Zech showsPrec :: Int -> WitnessZech p m -> ShowS # show :: WitnessZech p m -> String # showList :: [WitnessZech p m] -> ShowS # |
data SomeWitnessZech Source #
forall p m. SomeWitnessZech (WitnessZech p m) |
Instances
Show SomeWitnessZech Source # | |
Defined in Math.FiniteField.GaloisField.Zech showsPrec :: Int -> SomeWitnessZech -> ShowS # show :: SomeWitnessZech -> String # showList :: [SomeWitnessZech] -> ShowS # |
mkZechField :: Int -> Int -> Maybe SomeWitnessZech Source #
unsafeZechField :: Int -> Int -> SomeWitnessZech Source #
constructZechField :: SNat64 p -> SNat64 m -> Maybe (WitnessZech p m) Source #
Field elements
data Zech (p :: Nat) (m :: Nat) Source #
An element of the field GF(p^m)
Implementation note:
Field elements are represented by integers from the interval [-1...q-2]
:
-1
corresponds to0
0
corresponds to1
1
corresponds tog
k
corresponds tog^k
Instances
Subfields
A field of size p^m
has a unique subfield of size p^k
for all k|m
.
The Conway polynomials are constructed so that the Conway polynomials of
the subfields are compatible with the Conway polynomial of the ambient
field, in the sense that the canonical primitive generators g
of the ambient field
and h
of the
h = g ^ ((p^m-1)/(p^k-1))
This makes implementing subfields in the the discrete log representation particularly simple.
data SubField (p :: Nat) (m :: Nat) (k :: Nat) Source #
A witness for the subfield GF(p,k)
of GF(p,m)
ambientWitness :: SubField p m k -> WitnessZech p m Source #
witness for the ambient field
subFieldWitness :: SubField p m k -> WitnessZech p k Source #
witness for the existence of the subfield
subFieldProof :: SubField p m k -> Divides k m Source #
proof that k
divides m
subFieldName :: SubField p m k -> String Source #
Returns something like "GF(p^3) ⊆ GF(p^6)"
data SomeSubField (p :: Nat) (m :: Nat) Source #
Some subfield of GF(p,m)
forall k. SomeSubField (SubField p m k) |
Instances
Show (SomeSubField p m) Source # | |
Defined in Math.FiniteField.GaloisField.Zech showsPrec :: Int -> SomeSubField p m -> ShowS # show :: SomeSubField p m -> String # showList :: [SomeSubField p m] -> ShowS # |
constructSubField :: WitnessZech p m -> Divides k m -> SubField p m k Source #
enumerateSubFields :: forall p m. WitnessZech p m -> [SomeSubField p m] Source #