use std::{marker::PhantomData, convert, fmt}; use crate::SigType; /// A RedJubJub signature. pub struct Signature { bytes: [u8; 64], _marker: PhantomData, } impl From<[u8; 64]> for Signature { fn from(bytes: [u8; 64]) -> Signature { Signature { bytes, _marker: PhantomData, } } } impl From> for [u8; 64] { fn from(s: Signature) -> [u8; 64] { s.bytes } } // These impls all only exist because of array length restrictions. // XXX print the type variable impl fmt::Debug for Signature { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { //f.debug_tuple("Signature").field(&self.0[..]).finish() f.debug_tuple("Signature").finish() } } impl Copy for Signature {} impl Clone for Signature { fn clone(&self) -> Self { let mut bytes = [0; 64]; bytes[..].copy_from_slice(&self.bytes[..]); Signature { bytes, _marker: PhantomData, } } } impl PartialEq for Signature { fn eq(&self, other: &Self) -> bool { self.bytes[..] == other.bytes[..] } } impl Eq for Signature {}