Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,34 @@
// See: https://github.com/mcarton/rust-derivative/issues/115
#![allow(clippy::non_canonical_partial_ord_impl, unused_imports)]

use arbitrary::{Arbitrary, Unstructured};
use bitvec::vec::BitVec;
#[cfg(feature = "ark-serialize")]
use core::fmt::{self, Display, Formatter};
use core::marker::PhantomData;
use derivative::Derivative;
use derive_more::{AsRef, Into};
use sha3::digest::{
crypto_common::generic_array::{ArrayLength, GenericArray},
Digest,
};
use sha3::Keccak256;
#[cfg(feature = "ark-serialize")]
use core::str::FromStr;
use std::{
convert::{TryFrom, TryInto},
fmt::Debug,
hash::Hash,
};

use arbitrary::{Arbitrary, Unstructured};
#[cfg(feature = "ark-serialize")]
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
#[cfg(feature = "ark-serialize")]
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "ark-serialize")]
use core::str::FromStr;
#[cfg(feature = "ark-serialize")]
use tagged_base64::{Tagged, TaggedBase64, Tb64Error};

use bitvec::vec::BitVec;
use derivative::Derivative;
use derive_more::{AsRef, Into};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sha3::{
digest::{
crypto_common::generic_array::{ArrayLength, GenericArray},
Digest,
},
Keccak256,
};
#[cfg(feature = "ark-serialize")]
use tagged_base64::{Tagged, TaggedBase64, Tb64Error};

type Array = [u8; 32];

Expand All @@ -56,13 +57,13 @@ pub trait Committable {
#[derive(Derivative, AsRef, Into)]
#[derivative(
Copy(bound = ""),
Debug(bound = ""),
PartialEq(bound = ""),
Eq(bound = ""),
PartialOrd(bound = ""),
Ord(bound = ""),
Hash(bound = "")
)]
#[cfg_attr(not(feature = "ark-serialize"), derivative(Debug(bound = "")))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(
feature = "serde",
Expand Down Expand Up @@ -207,6 +208,13 @@ impl<T: ?Sized + Committable> From<&Commitment<T>> for TaggedBase64 {
}
}

#[cfg(feature = "ark-serialize")]
impl<T: ?Sized + Committable> Debug for Commitment<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
<Self as Display>::fmt(self, f)
}
}
Comment thread
ss-es marked this conversation as resolved.
Resolved

#[cfg(feature = "ark-serialize")]
impl<T: ?Sized + Committable> Display for Commitment<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -313,9 +321,10 @@ impl<T: Committable> RawCommitmentBuilder<T> {

#[cfg(all(test, feature = "ark-serialize", feature = "serde"))]
mod test {
use super::*;
use std::{fmt::Debug, hash::Hash};

use super::*;

struct DummyCommittable;
impl Committable for DummyCommittable {
fn commit(&self) -> Commitment<Self> {
Expand Down Expand Up @@ -413,9 +422,10 @@ mod test {

#[cfg(test)]
mod test_quickcheck {
use super::INVALID_UTF8;
use quickcheck_macros::quickcheck;

use super::INVALID_UTF8;

#[quickcheck]
fn invalid_utf8_is_invalid(pref: Vec<u8>, suff: Vec<u8>) {
let s = pref
Expand Down
Loading