Group Theory

The values within our circuits are elements of what is known as a finite field. To understand this, we need a bit of abstract algebra background, especially group theory.

Groups

A group is a set equipped with a binary operation that combines any two elements to form a third element, satisfying certain properties. A group is shown as and consists of the following components:

  • A set of elements .
  • A binary operation (denoted as ) that takes two elements and produces a third element.

The operation must satisfy the following properties:

  • Closure: For any two elements , the result of the operation is also in the group: . It is said that the group is closed under its binary operation.

  • Identity: There exists an element , called the identity element, such that for any element , the operation .

  • Inverse: For every element , there exists an element , called the inverse of a, such that . The inverse of is denoted as .

  • Associativity: For any three elements , the operation is associative, meaning . This property ensures that the order of operations does not matter.

There is an additional property as well, called the commutative property or abelian property. A group is said to be Abelian if the binary operation is commutative, meaning for all elements .

If the group has a finite number of elements, it is called a finite group.

Operation Notation

For the binary operation, we can use the additive notation or multiplicative notation.

  • Additive:
  • Multiplicative:

Examples

  • The integers under addition .
  • The integers modulo under addition .

Rings

A ring is a set equipped with two binary operations, addition and multiplication, that satisfy certain axioms. A ring consists of the following components:

  • A set of elements .
  • An addition operation (denoted as ) that takes two elements and produces a third element.
  • A multiplication operation (denoted as ) that takes two elements and produces a third element.

The operations must satisfy the following properties:

  • Additive + Multiplicative Closure: For any two elements , the result of the addition is also in the ring: and the result of the multiplication is also in the ring: . The ring is closed under both addition and multiplication.

  • Additive + Multiplicative Associativity: For any three elements , the addition and multiplication operations are associative, meaning and . This property ensures that the order of operations does not matter.

  • Additive Identity: There exists an element , called the additive identity, such that for any element , the addition . Nothing is said about multiplication yet.

  • Additive Inverse: For every element , there exists an element , called the additive inverse of , such that . The inverse of is denoted as .

  • Addition Commutativity: The addition operation is commutative, meaning for all elements .

  • Distributivity: For any three elements , the ring satisfies the distributive property, meaning and .

If the ring has a multiplicative identity, i.e., an element such that for all , then the ring is called a ring with unity and that element is called a unity.

If the multiplication is commutative, then the ring is called a commutative ring.

If the ring has a finite number of elements, it is called a finite ring.

Examples

  • The set of all integers, and is a commutative ring with unity.
  • The set of all rational numbers.
  • The set of all real numbers.
  • The set of all complex numbers.

Fields

A field is a ring with the following properties:

  • is a commutative ring.
  • There is a non-zero unity .
  • Every non-zero element have a multiplicative inverse such that .

If the field has a finite number of elements, it is called a finite field. The ring of integers modulo , denoted as , where is a prime number, is a finite field. This one is particularly important in cryptography!

In Circom, when you choose a prime with -p or --prime option, you actually choose the order of the finite field that the circuit will be built upon. Here is quick snippet to see the order yourself within the circuit:

template OrderMinus1() {
    log("P - 1 = ", -1);
}

This will print a huge number on your screen, and that number equals in the field; adding 1 to that gives you the order.