pub trait Field:
ff_field
+ FromUniformBytes<64>
+ Hash
+ Ord
+ Serialize
+ for<'de> Deserialize<'de>
+ HasByteRepresentation
+ Zeroizable { }Expand description
The primary finite field used within a GKR circuit, as well as within
sumcheck. Note that the field’s size should be large enough such that
depth(C) * deg(C) / |F| bits of computational soundness is considered
secure, where depth(C) is the depth of the GKR circuit and deg(C) is
the maximum degree of any layerwise polynomial relationship.
§Note
We use the Halo2 implementation of BN-256’s scalar field (crate::Fr) everywhere currently for testing purposes, as well as the Halo2 implementation of BN-256’s curve elements (crate::Bn256Point) within Hyrax as Pedersen group elements. The Halo2 implementation of BN-256’s base field (crate::Fq) is also available as a re-export, although this is not used in any circuits by default.
§Sub-traits
- [FromUniformBytes] – see associated trait documentation for more details.
Our use-case is specifically for compatibility with Poseidon, which we
are using as the hash function instantiation of a verifier’s public coins (see
implblock for Poseidon::new, for example). - Hash – necessary for creating a hashed representation of a circuit,
as well as storing Field values within data structures e.g.
HashMap. - Ord – not strictly necessary for cryptographic purposes, but useful for comparing elements against one another. Consider replacing with Eq.
- Serialize, Deserialize – necessary for writing values to file using Serde.
- HasByteRepresentation – necessary for converting a field element into its u8 limbs. This is useful for e.g. computing a block-based hash function over a field whose num bytes integer representation does not evenly divide the hash function’s block size (e.g. a 136-bit field against a 256-bit hash block).
- Zeroizable – necessary for actively over-writing otherwise sensitive values which may still be stored in RAM (e.g. blinding factors within a Hyrax commitment, or intermediate MLE values within a GKR circuit).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.