1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! # field-cat
//!
//! Finite field algebra for the `*-cat` proof-system ecosystem.
//!
//! `field-cat` owns the [`Field`] trait, the [`FieldBytes`]
//! transcript-serialization trait, and a small library of concrete
//! prime fields used by downstream proof-system crates
//! ([`plonkish_cat`](https://github.com/MavenRain/plonkish-cat),
//! [`proof_cat`](https://github.com/MavenRain/proof-cat), and
//! `stark-cat`).
//!
//! Lifting [`Field`] out of `plonkish-cat` lets STARK-flavored
//! downstreams depend only on the algebra they need, without
//! inheriting the `PLONKish` constraint vocabulary
//! (`ConstraintSet`, `Expression`, `Wire`, `CopyConstraint`).
//!
//! # Fields
//!
//! - [`F101`]: toy field with modulus `101`, useful for tests and
//! small inspectable examples.
//! - [`BabyBear`]: Mersenne prime field with modulus `2^31 - 1`,
//! used by Plonky3 and SP1.
//! - [`BFieldElement`]: Goldilocks prime field with modulus
//! `2^64 - 2^32 + 1`, used by Triton VM, Risc0, and Plonky3 in
//! its wider-field modes.
//!
//! # Adding a field
//!
//! Define a newtype, implement the [`std::ops`] arithmetic traits
//! (`Add`, `Sub`, `Mul`, `Neg`), implement [`Field`] (`zero`,
//! `one`, `inv`), and implement [`FieldBytes`] if the element
//! will be absorbed into a Fiat-Shamir transcript.
pub use BabyBear;
pub use BFieldElement;
pub use FieldBytes;
pub use Error;
pub use F101;
pub use Field;