Expand description
§RustCrypto: Generic Prime Fields
Generic implementation of prime fields built on crypto-bigint, along with macros for writing
field element newtypes including ones with formally verified arithmetic using fiat-crypto.
§About
A prime field is a finite field of order 𝑝, where 𝑝 is a prime number. Because 𝑝 is prime, every non-zero element of the field has a modular inverse.
Prime fields are notable for their use in cryptography, particularly for their use as coordinates (a.k.a. base field) and the scalar field of elliptic curve implementations.
The implementation provided by this crate is built on crypto_bigint::modular, which provides
a generic implementation of modular arithmetic with a modulus fixed at compile-time.
§Minimum Supported Rust Version (MSRV) Policy
MSRV increases are not considered breaking changes and can happen in patch releases.
The crate MSRV accounts for all supported targets and crate feature combinations, excluding explicitly unstable features.
§License
Licensed under either of:
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Re-exports§
pub use bigint;pub use bigint::hybrid_array as array;pub use ff;pub use rand_core;pub use subtle;pub use zeroize;
Modules§
Macros§
- fiat_
bernstein_ yang_ invert - Emit wrapper function for a
fiat-cryptogenerated implementation of the Bernstein-Yang (a.k.a. safegcd) modular inversion algorithm. - field_
op - Emit a
core::opstrait wrapper for an inherent method which is expected to be provided by a backend arithmetic implementation (e.g.fiat-crypto) - monty_
field_ arithmetic - Add
const fnmethods to the given field element for performing field arithmetic operations, e.g.add,double,sub,multiply,neg. - monty_
field_ element - Implements a field element type whose internal representation is in
Montgomery form, providing a combination of trait impls and inherent impls
which are
const fnwhere possible. - monty_
field_ fiat_ arithmetic - Add
fiat-cryptosynthesized arithmetic impls to the given field element. - monty_
field_ params - Creates a ZST representing the Montgomery parameters for a given field modulus.
- monty_
field_ params_ with_ root_ of_ unity - Same as
monty_field_params!, but with a precomputedROOT_OF_UNITYconstant. - test_
field_ identity - Implement field element identity tests.
- test_
field_ invert - Implement field element inversion tests.
- test_
field_ sqrt - Implement field element square root tests.
- test_
primefield - Implement all tests for a type which impls the
PrimeFieldtrait. - test_
primefield_ constants - Implement tests for constants defined by the
PrimeFieldtrait.
Structs§
- Error
- Error type.
- Monty
Field Element - Field element type which uses an internal Montgomery form representation.
Enums§
- Byte
Order - Byte order used when encoding/decoding field elements as bytestrings.
Traits§
- Monty
Field Params - Extension trait for defining additional field parameters beyond the ones provided by
ConstMontyParams.
Functions§
- compute_
t - Compute
t = (modulus - 1) >> S
Type Aliases§
- Monty
Field Bytes - Serialized representation of a field element.
- Result
- Result type.