Documentation

Elligator.Elligator1.bitsToNatProperties

bitsToNat Properties #

This file establishes that binary evaluation identifies length-n bit-vectors with the natural numbers below 2 ^ n. It also records consequences used by the Elligator string encoding.

Main results #

References #

See [bernstein2013a], Section 3.4, Theorem 4.

Every bit-vector of length n has binary value less than 2^n.

theorem Elligator.Elligator1.bitsToNat_succ {n : } (τ : Fin (n + 1)Bool) :
bitsToNat τ = (2 * bitsToNat fun (i : Fin n) => τ i.succ) + if τ 0 = true then 1 else 0

Splitting off the least significant bit gives the standard binary recurrence.

@[simp]

Prefixing a zero bit doubles the value of the remaining bits.

@[simp]

Prefixing a one bit doubles the value of the remaining bits and adds one.

bitsToNat is injective: distinct bit-vectors give distinct natural numbers.

theorem Elligator.Elligator1.bitsToNat_surj (n m : ) (hm : m < 2 ^ n) :
∃ (τ : Fin nBool), bitsToNat τ = m

Every natural number less than 2^n is the binary value of some bit-vector.

This statement doesn't use Function.surjective since it is not viable to get hm into the ∀ m value.

theorem Elligator.Elligator1.natCast_injective_of_prime_card {F : Type u_1} [Field F] [Fintype F] {q : } (hq_card : Fintype.card F = q) (q_prime : Prime q) (a b : ) (ha : a < q) (hb : b < q) (h : a = b) :
a = b
theorem Elligator.Elligator1.lower_half_neg_eq {F : Type u_1} [Field F] [Fintype F] {q : } (hq_card : Fintype.card F = q) (hq : Prime q) {a b : } (ha : a (q - 1) / 2) (hb : b (q - 1) / 2) (heq : a = -b) :
a = b
theorem Elligator.Elligator1.σ_injective {F : Type u_1} [Field F] [Fintype F] {q : } (hq_card : Fintype.card F = q) (q_prime : Prime q) (hq_mod : q % 4 = 3) :
theorem Elligator.Elligator1.exists_S_elem_of_le {q : } (hq_mod : q % 4 = 3) (n : ) (hle : n (q - 1) / 2) :
∃ (τ : S), bitsToNat τ = n
theorem Elligator.Elligator1.exists_σ_preimage_or_neg {F : Type u_1} [Field F] [Fintype F] {q : } (hq_card : Fintype.card F = q) (q_prime : Prime q) (hq_mod : q % 4 = 3) (t : F) :
∃ (τ : S), σ τ = t σ τ = -t

Every field element has a representative in S up to sign. For prime q with q ≡ 3 (mod 4) and any t : F, there is a string τ ∈ S such that σ τ = t or σ τ = -t. This is the lower-half representative argument used to prove that the string encoding covers all of ϕ(F) in Theorem 4.