Skip to main content

Module tower

Module tower 

Source
Expand description

The shipped quadratic binary extension instances.

The Rijndael and Fan-Paar towers are ExtensionSpec<2> instances: each names the field FiniteField<2, N, Extension<S, 2>> as a + b*t over the previous level, under the relation t^2 + c1*t + c0 = 0. The low N/2 coordinate bits hold a and the high N/2 bits hold b; storage bits at or above N are zero. One is the base one in the low component. The scalar identities are:

product:   (a*c + c0*b*d, a*d + b*c + c1*b*d)
square:    (a^2 + c0*b^2, c1*b^2)
conjugate: (a + c1*b, b)
norm:      a^2 + c1*a*b + c0*b^2

Rijndael16, Rijndael32, and Rijndael64 root at the AES field with c1 = 1 and c0 equal to 0x20, 0x2000, and 0x2000_0000. The Fan-Paar specs nest from GF(2) through the Wiedemann relation t^2 + alpha*t + 1, where alpha is the previous level’s indeterminate (1 over GF(2), then the raw base_one << (h/2) in its own packing). FanPaar2 and FanPaar4 keep their coordinate word in a padded byte and carry no byte buffer; every other instance fills its u8, u16, u32, or u64 word exactly and encodes it little-endian.

Each instance carries its frozen generator and a full const surface on its concrete element type: constructors, byte and component conversions, and arithmetic, plus mul_alpha on Fan-Paar GF(2^8), GF(2^16), and GF(2^32). The const methods and the row’s Field arithmetic share one specialized body per instance: the Rijndael rows run the Karatsuba recurrence over the AES field, the wide Fan-Paar rows the Wiedemann recurrence, and Fan-Paar GF(2^2) through GF(2^8) the descriptor interpreter. An extension row whose presentation equals a shipped instance’s — base presentation, relation, and storage — runs that instance’s body; every other row runs the generic extension body.

use fgf::{Elem, Extension, FiniteField, Rijndael16};

type Gf16 = FiniteField<2, 16, Extension<Rijndael16, 2>>;

let x = Elem::<Gf16>::from_raw(0x1234);
assert_eq!(x.mul(Elem::<Gf16>::ONE), x);
assert_eq!(Elem::<Gf16>::GENERATOR.pow(65_535), Elem::<Gf16>::ONE);

// Components are the base-field coefficients of `1` and `t`.
let [low, high] = x.to_components();
assert_eq!((low.to_raw(), high.to_raw()), (0x34, 0x12));
assert_eq!(Elem::<Gf16>::from_components([low, high]), x);

Structs§

FanPaar2
Fan-Paar GF(2^2) over GF(2): t^2 + t + 1.
FanPaar4
Fan-Paar GF(2^4) over Fan-Paar GF(2^2): t^2 + 0x2*t + 1.
FanPaar8
Fan-Paar GF(2^8) over Fan-Paar GF(2^4): t^2 + 0x4*t + 1.
FanPaar16
Fan-Paar GF(2^16) over Fan-Paar GF(2^8): t^2 + 0x10*t + 1.
FanPaar32
Fan-Paar GF(2^32) over Fan-Paar GF(2^16): t^2 + 0x0100*t + 1.
FanPaar64
Fan-Paar GF(2^64) over Fan-Paar GF(2^32): t^2 + 0x0001_0000*t + 1.
Rijndael16
The Rijndael-rooted extension of the AES field: t^2 + t + 0x20.
Rijndael32
The Rijndael-rooted extension of Rijndael GF(2^16): v^2 + v + 0x2000.
Rijndael64
The Rijndael-rooted extension of Rijndael GF(2^32): w^2 + w + 0x2000_0000.

Functions§

fp_invert
Recursive conjugate-and-norm inversion, with inv(0) = 0.
fp_mul_alpha
Multiply by the top-level indeterminate of a bits-wide level.
fp_multiply
Recursive Fan-Paar multiplication with a log-table byte base.
fp_square
Recursive squaring through the linear recurrence.