From c2d63b214a32378f8d5644757e1091b16775e84e Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Mon, 26 Nov 2018 17:04:50 +0100 Subject: [PATCH] Add missing_docs lint, extend docs. --- src/error.rs | 4 ++++ src/lib.rs | 6 +++++- src/mock/ms8.rs | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 145bd7e..13f5b71 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,10 +5,13 @@ use failure::Fail; /// A crypto error. #[derive(Clone, Eq, PartialEq, Debug, Fail)] pub enum Error { + /// Not enough signature shares. #[fail(display = "Not enough signature shares")] NotEnoughShares, + /// Signature shares contain a duplicated index. #[fail(display = "Signature shares contain a duplicated index")] DuplicateEntry, + /// The degree is too high for the coefficients to be indexed by `usize`. #[fail(display = "The degree is too high for the coefficients to be indexed by usize.")] DegreeTooHigh, } @@ -32,6 +35,7 @@ mod tests { /// An error reading a structure from an array of bytes. #[derive(Clone, Eq, PartialEq, Debug, Fail)] pub enum FromBytesError { + /// Invalid representation #[fail(display = "Invalid representation.")] Invalid, } diff --git a/src/lib.rs b/src/lib.rs index 2bd8dd3..0d2f28e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +//! A pairing-based threshold cryptosystem for collaborative decryption and signatures. + // Clippy warns that it's dangerous to derive `PartialEq` and explicitly implement `Hash`, but the // `pairing::bls12_381` types don't implement `Hash`, so we can't derive it. #![cfg_attr(feature = "cargo-clippy", allow(derive_hash_xor_eq))] @@ -10,6 +12,7 @@ ), allow(trivially_copy_pass_by_ref) )] +#![warn(missing_docs)] #[cfg(test)] extern crate bincode; @@ -31,10 +34,10 @@ pub extern crate pairing; mod into_fr; mod secret; +mod serde_impl; pub mod error; pub mod poly; -pub mod serde_impl; use std::fmt; use std::hash::{Hash, Hasher}; @@ -208,6 +211,7 @@ impl Hash for Signature { } impl Signature { + /// Returns `true` if the signature contains an odd number of ones. pub fn parity(&self) -> bool { let uncomp = self.0.into_affine().into_uncompressed(); let xor_bytes: u8 = uncomp.as_ref().iter().fold(0, |result, byte| result ^ byte); diff --git a/src/mock/ms8.rs b/src/mock/ms8.rs index f792dbc..9f27f8a 100644 --- a/src/mock/ms8.rs +++ b/src/mock/ms8.rs @@ -147,10 +147,12 @@ generate_op_impls!(Mersenne8, Mul, MulAssign, mul, mul_assign); impl Mersenne8 { #[inline] + /// Creates a new `Mersenne8`, with the value `v` modulo `MS8`. pub fn new(v: u32) -> Mersenne8 { Mersenne8(v % MS8) } + /// Takes `self` to the power of `exp`. #[inline] pub fn pow(self, exp: u32) -> Mersenne8 { Mersenne8(modular_pow(self.0, exp, MS8))