From 580b3107131ed97654c5092ca42019d576c2c898 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Mon, 2 Dec 2019 22:10:56 -0800 Subject: [PATCH] Add underivable impls to Signature. --- src/signature.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/signature.rs b/src/signature.rs index 3cfa75f..8042fee 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -1,3 +1,5 @@ +use std::{convert, fmt}; + /// A RedJubJub signature. pub struct Signature(pub [u8; 64]); @@ -12,3 +14,29 @@ impl From for [u8; 64] { s.0 } } + +// These impls all only exist because of array length restrictions. + +impl fmt::Debug for Signature { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("Signature").field(&self.0[..]).finish() + } +} + +impl Copy for Signature {} + +impl Clone for Signature { + fn clone(&self) -> Self { + let mut bytes = [0; 64]; + bytes[..].copy_from_slice(&self.0[..]); + Self(bytes) + } +} + +impl PartialEq for Signature { + fn eq(&self, other: &Self) -> bool { + self.0[..] == other.0[..] + } +} + +impl Eq for Signature {}