diff --git a/src/arithmetic.rs b/src/arithmetic.rs index 0fef7f5..8e711d2 100644 --- a/src/arithmetic.rs +++ b/src/arithmetic.rs @@ -17,6 +17,7 @@ pub use fields::*; /// performed. This allows an FFT implementation (for example) to operate /// generically over either a field or elliptic curve group. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub trait Group: Copy + Clone + Send + Sync + 'static { /// The group is assumed to be of prime order $p$. `Scalar` is the /// associated scalar field of size $p$. diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index d954893..4bd128f 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -23,6 +23,7 @@ use std::{ /// Currently requires the `std` feature flag because of `hash_to_curve`, and /// `CurveAffine::{read, write}`. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub trait CurveExt: PrimeCurve::AffineExt> + group::Group::ScalarExt> @@ -90,6 +91,7 @@ pub trait CurveExt: /// This trait is the affine counterpart to `Curve` and is used for /// serialization, storage in memory, and inspection of $x$ and $y$ coordinates. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub trait CurveAffine: PrimeCurveAffine< Scalar = ::ScalarExt, @@ -145,6 +147,7 @@ pub trait CurveAffine: /// The affine coordinates of a point on an elliptic curve. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[derive(Clone, Copy, Debug, Default)] pub struct Coordinates { pub(crate) x: C::Base, diff --git a/src/arithmetic/fields.rs b/src/arithmetic/fields.rs index dbea4f8..ce98a0f 100644 --- a/src/arithmetic/fields.rs +++ b/src/arithmetic/fields.rs @@ -20,6 +20,7 @@ const_assert!(size_of::() >= 4); /// A trait that exposes additional operations related to calculating square roots of /// prime-order finite fields. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub trait SqrtRatio: ff::PrimeField { /// The value $(T-1)/2$ such that $2^S \cdot T = p - 1$ with $T$ odd. const T_MINUS1_OVER2: [u64; 4]; @@ -65,6 +66,7 @@ pub trait SqrtRatio: ff::PrimeField { /// This trait is a common interface for dealing with elements of a finite /// field. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub trait FieldExt: SqrtRatio + From + Ord + Group { /// Modulus of the field written as a string for display purposes const MODULUS: &'static str; @@ -119,6 +121,7 @@ pub trait FieldExt: SqrtRatio + From + Ord + Group { /// /// `tm1d2` should be set to `(t - 1) // 2`, where `t = (modulus - 1) >> F::S`. #[cfg(not(feature = "std"))] +#[cfg_attr(docsrs, doc(cfg(not(feature = "std"))))] pub(crate) fn sqrt_tonelli_shanks>( f: &F, tm1d2: S, @@ -165,6 +168,7 @@ pub(crate) fn sqrt_tonelli_shanks>( /// Parameters for a perfect hash function used in square root computation. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[derive(Debug)] struct SqrtHasher { hash_xor: u32, @@ -186,6 +190,7 @@ impl SqrtHasher { /// Tables used for square root computation. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[derive(Debug)] pub struct SqrtTables { hasher: SqrtHasher, diff --git a/src/curves.rs b/src/curves.rs index 8661033..7a0db20 100644 --- a/src/curves.rs +++ b/src/curves.rs @@ -103,6 +103,7 @@ macro_rules! new_curve_impl { } #[cfg(feature = "std")] + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl group::WnafGroup for $name { fn recommended_wnaf_for_num_scalars(num_scalars: usize) -> usize { // Copied from bls12_381::g1, should be updated. diff --git a/src/fields/fp.rs b/src/fields/fp.rs index d27928f..d56dd3f 100644 --- a/src/fields/fp.rs +++ b/src/fields/fp.rs @@ -225,6 +225,7 @@ const ROOT_OF_UNITY: Fp = Fp::from_raw([ /// with t odd. In other words, this /// is a t root of unity. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] const DELTA: Fp = Fp::from_raw([ 0x6a6ccd20dd7b9ba2, 0xf5e4f3f13eee5636, @@ -464,6 +465,7 @@ impl<'a> From<&'a Fp> for [u8; 32] { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl Group for Fp { type Scalar = Fp; @@ -623,6 +625,7 @@ type ReprBits = [u32; 8]; type ReprBits = [u64; 4]; #[cfg(feature = "bits")] +#[cfg_attr(docsrs, doc(cfg(feature = "bits")))] impl PrimeFieldBits for Fp { type ReprBits = ReprBits; @@ -666,10 +669,12 @@ impl PrimeFieldBits for Fp { #[cfg(feature = "std")] lazy_static! { // The perfect hash parameters are found by `squareroottab.sage` in zcash/pasta. + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] static ref FP_TABLES: SqrtTables = SqrtTables::new(0x11BE, 1098); } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl SqrtRatio for Fp { const T_MINUS1_OVER2: [u64; 4] = T_MINUS1_OVER2; @@ -721,6 +726,7 @@ impl SqrtRatio for Fp { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl FieldExt for Fp { const MODULUS: &'static str = "0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001"; diff --git a/src/fields/fq.rs b/src/fields/fq.rs index f7111be..5b100fe 100644 --- a/src/fields/fq.rs +++ b/src/fields/fq.rs @@ -225,6 +225,7 @@ const ROOT_OF_UNITY: Fq = Fq::from_raw([ /// with t odd. In other words, this /// is a t root of unity. #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] const DELTA: Fq = Fq::from_raw([ 0x8494392472d1683c, 0xe3ac3376541d1140, @@ -464,6 +465,7 @@ impl<'a> From<&'a Fq> for [u8; 32] { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl Group for Fq { type Scalar = Fq; @@ -666,10 +668,12 @@ impl PrimeFieldBits for Fq { #[cfg(feature = "std")] lazy_static! { // The perfect hash parameters are found by `squareroottab.sage` in zcash/pasta. + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] static ref FQ_TABLES: SqrtTables = SqrtTables::new(0x116A9E, 1206); } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl SqrtRatio for Fq { const T_MINUS1_OVER2: [u64; 4] = T_MINUS1_OVER2; @@ -721,6 +725,7 @@ impl SqrtRatio for Fq { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl FieldExt for Fq { const MODULUS: &'static str = "0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001";