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