aboutsummaryrefslogtreecommitdiff
path: root/docs/journal/pages/finite-fields.md
blob: b9f9eb4d005c8faf814f7c02fe47f71af4b57aa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
> [Index](../README.md)

# Finite Fields

One of the mathematical principles underpinning the PLONK proof systems are finite fields. These are used in both the PLONK circuits themselves, but also in the eliptic curve pairings necessary for the proof system.

In PLONKers!, we are building a very specific PLONK construction over the BLS12-381 curve. This curve is defined over a finite field with a prime modulus. This sounds complicated, but it really means that:

- `p = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787`, a very large prime
- It is the set of integers from `0` to `p - 1` (inclusive)
- Addition and multiplication are done modulo `p`
- Substraction is the addition of the additive inverse (`-a = p - a`, so `a + (-a) = 0` for all `a`)
- Division is the multiplication by the multiplicative inverse (`1/a = a ^ (p - 2) mod p`, so `a * (1/a) = a * a (p - 2) = a ^ (p - 1) = 1` by Fermat's little theorem for all `a` except `0`, where inverse of `0` is defined to be `0`). Note that multiplicative inverses can also be computed with the extended Euclidean algorithm and Bézout's identity.

And with this we build the "numbers" that we use for PLONK and eliptic curve operations.

# Resources

- [BLS12-381 For The Rest Of Us](https://hackmd.io/@benjaminion/bls12-381)
- [`ethereum/py_ecc`](https://github.com/ethereum/py_ecc)

> [Index](../README.md)