Learning Cryptography, Part 1: Finite Fields (2024)

Learning Cryptography, Part 1: Finite Fields (3)

Loopring is creating a new “Learning Cryptography” series to educate the wider crypto community about this fascinating field. This series will begin from the basics, and work its way up to the advanced tools that make our scalable 3.0 DEX protocol — which utilizes zero-knowledge proofs — possible.

For many developers like myself, understanding cryptography feels like a dark art/magic. It’s not that we find math hard, in fact, many of us probably excelled in it in high school/college courses.

The problem lies with the fact that there’s no resource which balances the mathematics and presentation of ideas in an easy-to-understand manner. Facing this problem first hand, I decided to start this series to consolidate my learning, but also help various developers in their journey of understanding cryptography.

After reading through enough of these articles you should be able to understand and grasp more complicated cryptographic primitives in detail such as zero-knowledge proofs, threshold relay signatures and more.

Mathematical notations will gradually be introduced but pictures and repeated explanations will be present so you should hopefully be able to follow along!

Learning Cryptography, Part 1: Finite Fields (4)

Finite Fields, also known as Galois Fields, are cornerstones for understanding any cryptography. A field can be defined as a set of numbers that we can add, subtract, multiply and divide together and only ever end up with a result that exists in our set of numbers. This is particularly useful for crypto as we can deal with a limited set of extremely large numbers.

To have a finite field you need the following properties (the dot symbol · denotes the remainder after multiplying/adding two elements):

  • Closed — any operation performed with elements from the set returns an element contained in the original set.
  • Associative — if you have (a· b) ·c, it’s the same as a ·(b ·c)
  • Identity — there exists a neutral element (usually 1) such that a · 1 = a
  • Inverse — within the set there’s another element such that a · (a)^-1= 1
  • Commutative — the order of operations doesn’t matter: a · b = b · a

The most crucial property of a finite field is that it has p^m elements where p is a prime number and m is whatever you choose. A finite field with 11 elements can be defined as GF(11^1). A finite field with 256 elements would be written as GF(2^8). You can’t have a finite field with 12 elements since you’d have to write it as 2^2 * 3 which breaks the convention of p^m.

With our notation of GF(p^m):

  • If m = 1 then we get prime fields
  • If m > 1 then we get extension fields. This is a key point as it links to what we’re going to do with elliptic curves down the line. When m = 2 we get plenty of super interesting results as well.
Learning Cryptography, Part 1: Finite Fields (5)

The notation GF(p) means we have a finite field with the integers {0, … , p-1}. Suppose we have GF(5), our initial set will be {0, 1, 2, 3, 4}. Let’s put this into practice by trying out different operations. Any operations we do below should return 0, 1, 2, 3 or 4 (closure property).

Learning Cryptography, Part 1: Finite Fields (6)

Addition:

(3 + 4) mod 5 = 2
(1 + 4) mod 5 = 0
(1 + 2) mod 5 = 3

Subtraction:

(4 - 0) mod 5 = 4
(4 - 2) mod 5 = 2
(3 - 0) mod 5 = 1

Multiplication:

(0 * 4) mod 5 = 0
(2 * 4) mod 5 = 3
(3 * 4) mod 5 = 2

Division/Inversion:

(4 * 4) mod 5 = 1
(3 * 2) mod 5 = 1
(2 * 3) mod 5 = 1
(1 * 1) mod 5 = 1
(0 * ?) mod 5 = 1 // this doesn’t exist!
GCD(0, 5) = undefined!

It seemed like our finite field was coming along perfectly until we came across the identity for 0. So what do we do? Eliminate it and represent our field as F11* rather than F11. When referring to finite fields as F* it means 0 is not included as part of the set.

Learning Cryptography, Part 1: Finite Fields (7)

Unlike finite fields, whose elements are integers, extension fields’ elements are polynomials. Extension fields = GF(2^m) where m > 1

These polynomials take the form of:

Learning Cryptography, Part 1: Finite Fields (8)

To make it less cryptic, let’s use the example of GF(2^3) which will result in the equation form:

Learning Cryptography, Part 1: Finite Fields (9)

GF(2^3) = GF(8) which means there’ll be a total of 8 elements in this set.

If we write out the elements they’ll have the following values for (a2,a1,a0) where a1, a2 or a0 can only ever be 0 or 1.

(a2, a1, a0)(0, 0, 0) = 0
(0, 0, 1) = 1
(0, 1, 0) = x
(1, 0, 0) = x²
(0, 1, 1) = x+1
(1, 1, 0) = x²+x
(1, 0, 1) = x²+1
(1, 1, 1) = x²+x+1

Putting it all together, GF(2^3) = {0, 1, x, x², x+1, x²+x, x²+1, x²+x+1}

Although this form looks much different from our integers, we can still do our addition, subtraction, multiplication, and division and return an element in our set.

To keep it short and simple let’s addx²+1 andx²+x+1which gives us:

(1+1)x²+x+(1+1)

Since 1 + 1 mod 2 = 0, our equation simplifies to x which is contained in our original set!

Let’s try another example but a little bit harder.

A · B = (x²+1)(x²+x+1)
= x⁴+x³+x²+x²+1
= x⁴+x³+(1+1)x²+1
= x⁴+x³+1

Unfortunately, x⁴+x³+1 doesn’t exist in our finite field. So what do we do? Cue irreducible polynomials which are defined as polynomials which can’t be broken down into smaller polynomials (from the power of original polynomial).

In the case of GF(2^3) our irreducible polynomial is x³+x+1. If we divide x⁴+ x³+1 with our irreducible prime, we ultimately getx²+x which exists in our set — yay!

It seems quite mundane to go over such a basic concept in detail, but without doing so it can lead to difficulty understanding more advanced concepts down the line, especially when it comes to the generalized discrete logarithm problem and elliptic curve cryptography!

Learning Cryptography, Part 1: Finite Fields (2024)

FAQs

How do you find the finite field in cryptography? ›

To have a finite field you need the following properties (the dot symbol · denotes the remainder after multiplying/adding two elements): Closed — any operation performed with elements from the set returns an element contained in the original set. Associative — if you have (a· b) ·c , it's the same as a ·(b ·c)

What is the role of finite fields in cryptographic algorithms? ›

Efficient computation: Finite fields enable efficient arithmetic operations, making them suitable for cryptographic algorithms and error-correcting codes. Algebraic properties: Finite fields provide a rich algebraic structure that is useful for designing cryptographic systems with provable security properties.

Why are finite fields important? ›

Finite fields are widely used in number theory, as many problems over the integers may be solved by reducing them modulo one or several prime numbers.

What is a field in cryptography? ›

This is a mathematical concept that is essential to understand Cryptography. Fields are a definite set of numbers in a given range that remain in the same group under a given binary operation. For instance, F is a field having elements (a, b, c, d …) for binary operations '+' and '*.

Are finite fields complete? ›

With respect to the discrete topology (or the discrete metric) the finite field is complete, because all Cauchy sequences are eventually constant (and therefore not very interesting).

Are all finite fields perfect? ›

In particular, all fields of characteristic zero and all finite fields are perfect. Perfect fields are significant because Galois theory over these fields becomes simpler, since the general Galois assumption of field extensions being separable is automatically satisfied over these fields (see third condition above).

What math is most important for cryptography? ›

Perhaps the main mathematical background needed in cryptography is probability theory since, as we will see, there is no secrecy without randomness. Luckily, we only need fairly basic notions of probability theory and in particular only probability over finite sample spaces.

Why is math important in cryptography? ›

The Foundation of Cryptography: Mathematical Principles. At its core, cryptography relies on mathematical principles to ensure the confidentiality, integrity, and authenticity of data. The most fundamental of these principles is the concept of encryption.

Why is cryptography important in math? ›

Cryptography uses mathematical algorithms to encode messages in a way that only the intended recipient can decode them, while keeping the message confidential from any unauthorized parties.

Are all finite fields cyclic? ›

The multiplicative group of any finite field is cyclic. This result follows from the more general result that we will prove in the next theorem. Theorem 22.10. If G is a finite subgroup of F∗, the multiplicative group of nonzero elements of a field F, then G is cyclic.

How many finite fields are there? ›

There are infinitely many different finite fields. Their number of elements is necessarily of the form pn where p is a prime number and n is a positive integer, and two finite fields of the same size are isomorphic.

How to construct a finite field? ›

Therefore, in order to construct a finite field, we may choose a modulus n (an integer greater than 1 ) and a polynomial p(α) and then check whether all non-zero polynomials in Zn[α]/(p(α)) Z n [ α ] / ( p ( α ) ) are invertible or not — if they are, then Zn[α]/(p(α)) Z n [ α ] / ( p ( α ) ) is a field.

What is the symbol for a finite field? ›

Definition 1 (Finite fields). Let p be a prime number, and n ≥ 1 an integer. A finite field of order pn, denoted by Fpn or GF(pn), is a collection of pn objects and two binary operations, addition and multiplication, such that the following properties hold: 1.

Can a finite field be ordered? ›

In particular, finite fields cannot be ordered. Every non-trivial sum of squares is nonzero.

Is every finite field commutative? ›

Wedderbrun's Theorem Every finite field is commutative. Proof: The statement of the theorem is very simple to understand, yet it is hard (if you're not an expert) to imagine why the axioms of a field and the finiteness assumption allow us to deduce that the field is commutative.

How do you find the number of elements in a finite field? ›

Their number of elements is necessarily of the form pn where p is a prime number and n is a positive integer, and two finite fields of the same size are isomorphic. The prime p is called the characteristic of the field, and the positive integer n is called the dimension of the field over its prime field.

What is the finite field in AES? ›

Finite Fields in AES:

These fields are constructed as extension fields over a prime field of size 2 (GF(2)). Finite fields are categorized into prime fields and extension fields. Prime Fields: Prime fields, denoted as GF(p), have a prime number p as their size. In AES, the prime field GF(2) is the base field.

Top Articles
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 6298

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.