Squashed 'ff/' changes from 661558e..ddff465
ddff465 Bump version and dependency on ff_derive 25d11d6 Bump version 95e2723 Bump version to 0.5.1 f76872a Add ?Sized to RngCore trait bounds (#14) 09a32b1 ff 0.5.0 32543ab Crate docs 22031dc Update READMEs 658fe6d CI: Check intra-doc links 35f5026 Add READMEs to Cargo.toml files 6804225 Migrate ff_derive to proc-macro2 1.0 b9a79ce cargo fmt 82574c2 cargo fix --edition-idioms for ff 3b0cf72 Add edition = 2018 8a2b51b Replace try! macro 40fc9ba cargo fix --edition for ff 22c67f3 cargo fmt 312141c Clarify masking of bits in Field::random impls 89a68e1 Migrate to rand 0.7 58415fb Migrate ff, group, pairing, and bellman to rand 0.6 8b6e6b1 Migrate ff to rand_core 0.3 (used by rand 0.5) git-subtree-dir: ff git-subtree-split: ddff4658ddd7496bb29cc636c391b7aaaca24673
This commit is contained in:
+11
-7
@@ -1,7 +1,8 @@
|
||||
#![allow(unused_imports)]
|
||||
//! This crate provides traits for working with finite fields.
|
||||
|
||||
extern crate byteorder;
|
||||
extern crate rand;
|
||||
// Catch documentation errors caused by code changes.
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
#[cfg(feature = "derive")]
|
||||
#[macro_use]
|
||||
@@ -10,14 +11,18 @@ extern crate ff_derive;
|
||||
#[cfg(feature = "derive")]
|
||||
pub use ff_derive::*;
|
||||
|
||||
use rand_core::RngCore;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
/// This trait represents an element of a field.
|
||||
pub trait Field:
|
||||
Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static + rand::Rand
|
||||
Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static
|
||||
{
|
||||
/// Returns an element chosen uniformly at random using a user-provided RNG.
|
||||
fn random<R: RngCore + ?std::marker::Sized>(rng: &mut R) -> Self;
|
||||
|
||||
/// Returns the zero element of the field, the additive identity.
|
||||
fn zero() -> Self;
|
||||
|
||||
@@ -100,7 +105,6 @@ pub trait PrimeFieldRepr:
|
||||
+ fmt::Debug
|
||||
+ fmt::Display
|
||||
+ 'static
|
||||
+ rand::Rand
|
||||
+ AsRef<[u64]>
|
||||
+ AsMut<[u64]>
|
||||
+ From<u64>
|
||||
@@ -207,7 +211,7 @@ impl Error for PrimeFieldDecodingError {
|
||||
}
|
||||
|
||||
impl fmt::Display for PrimeFieldDecodingError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match *self {
|
||||
PrimeFieldDecodingError::NotInField(ref repr) => {
|
||||
write!(f, "{} is not an element of the field", repr)
|
||||
@@ -263,7 +267,7 @@ pub trait PrimeField: Field {
|
||||
}
|
||||
|
||||
/// Convert this prime field element into a biginteger representation.
|
||||
fn from_repr(Self::Repr) -> Result<Self, PrimeFieldDecodingError>;
|
||||
fn from_repr(_: Self::Repr) -> Result<Self, PrimeFieldDecodingError>;
|
||||
|
||||
/// Convert a biginteger representation into a prime field element, if
|
||||
/// the number is an element of the field.
|
||||
|
||||
Reference in New Issue
Block a user