Documentation

QedShare.Field.Laws

Field laws for multiplication #

All laws are proved first for the textbook mulSpecByte / constant-time mulByte on bytes with bv_decide, then lifted to GF256.

bv_decide turns a goal about fixed-width bit vectors into a SAT problem and asks a SAT solver (CaDiCaL) for a proof. The solver's LRAT certificate is checked by compiled code, and each bv_decide call adds one auxiliary axiom (<theorem>._native.bv_decide.ax_…) recording that the checker accepted it (see README: What you have to trust).

theorem QedShare.GF256.mul_comm (a b : GF256) :
a * b = b * a

Multiplication is commutative.

theorem QedShare.GF256.mul_one (a : GF256) :
a * 1 = a

One is a right identity for multiplication.

theorem QedShare.GF256.one_mul (a : GF256) :
1 * a = a

One is a left identity for multiplication.

theorem QedShare.GF256.mul_zero (a : GF256) :
a * 0 = 0

Multiplying by zero gives zero.

theorem QedShare.GF256.zero_mul (a : GF256) :
0 * a = 0

Zero times anything is zero.

theorem QedShare.GF256.mul_add (a b c : GF256) :
a * (b + c) = a * b + a * c

Multiplication distributes over addition (left).

theorem QedShare.GF256.add_mul (a b c : GF256) :
(a + b) * c = a * c + b * c

Multiplication distributes over addition (right).

Associativity #

A direct bv_decide proof of associativity times out: it has 24 input bits and the circuit is mostly XORs, which SAT solvers handle badly. Instead, split a into its 8 bits (a = Σᵢ bitPart a i). Multiplication is linear in its left argument, so associativity for a follows from associativity for each single bit, and each of those is a much easier SAT problem (one free bit of a, plus b and c).

Bit i of a, kept in place: a &&& 2ⁱ.

Equations
Instances For

    Every byte is the XOR of its 8 bits.

    theorem QedShare.GF256.mulByte_xor_left (a a' b : UInt8) :
    mulByte (a ^^^ a') b = mulByte a b ^^^ mulByte a' b

    Byte multiplication is linear in its left argument (over XOR).

    theorem QedShare.GF256.assoc_bit (i : UInt8) (hi : i < 8) (a b c : UInt8) :
    mulByte (mulByte (bitPart a i) b) c = mulByte (bitPart a i) (mulByte b c)

    Associativity when the left factor has at most one bit set (bit i).

    theorem QedShare.GF256.mul_assoc (a b c : GF256) :
    a * b * c = a * (b * c)

    Multiplication is associative.