derive Debug for pods for BPF target as well

This commit is contained in:
Michael Vines 2021-10-05 09:05:02 -07:00
parent c150b4b197
commit 20c6001836
2 changed files with 28 additions and 28 deletions

View File

@ -21,7 +21,7 @@ mod target_arch {
range_proof::RangeProof,
},
curve25519_dalek::{ristretto::CompressedRistretto, scalar::Scalar},
std::{convert::TryFrom, fmt},
std::convert::TryFrom,
};
impl From<Scalar> for pod::Scalar {
@ -50,12 +50,6 @@ mod target_arch {
}
}
impl fmt::Debug for pod::ElGamalCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl From<ElGamalPubkey> for pod::ElGamalPubkey {
fn from(pk: ElGamalPubkey) -> Self {
Self(pk.to_bytes())
@ -70,12 +64,6 @@ mod target_arch {
}
}
impl fmt::Debug for pod::ElGamalPubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl From<CompressedRistretto> for pod::CompressedRistretto {
fn from(cr: CompressedRistretto) -> Self {
Self(cr.to_bytes())
@ -111,13 +99,6 @@ mod target_arch {
}
}
#[cfg(not(target_arch = "bpf"))]
impl fmt::Debug for pod::PedersenCommitment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
#[cfg(not(target_arch = "bpf"))]
impl From<PedersenDecryptHandle> for pod::PedersenDecryptHandle {
fn from(handle: PedersenDecryptHandle) -> Self {
@ -142,13 +123,6 @@ mod target_arch {
}
}
#[cfg(not(target_arch = "bpf"))]
impl fmt::Debug for pod::PedersenDecryptHandle {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl TryFrom<RangeProof> for pod::RangeProof64 {
type Error = ProofError;

View File

@ -1,4 +1,6 @@
use bytemuck::{Pod, Zeroable};
use std::fmt;
pub use bytemuck::{Pod, Zeroable};
#[derive(Clone, Copy, Pod, Zeroable, PartialEq)]
#[repr(transparent)]
@ -12,18 +14,42 @@ pub struct CompressedRistretto(pub [u8; 32]);
#[repr(transparent)]
pub struct ElGamalCiphertext(pub [u8; 64]);
impl fmt::Debug for ElGamalCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
#[derive(Clone, Copy, Pod, Zeroable, PartialEq)]
#[repr(transparent)]
pub struct ElGamalPubkey(pub [u8; 32]);
impl fmt::Debug for ElGamalPubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
#[derive(Clone, Copy, Pod, Zeroable, PartialEq)]
#[repr(transparent)]
pub struct PedersenCommitment(pub [u8; 32]);
impl fmt::Debug for PedersenCommitment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
#[derive(Clone, Copy, Pod, Zeroable, PartialEq)]
#[repr(transparent)]
pub struct PedersenDecryptHandle(pub [u8; 32]);
impl fmt::Debug for PedersenDecryptHandle {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}
/// Serialization of range proofs for 64-bit numbers (for `Withdraw` instruction)
#[derive(Clone, Copy)]
#[repr(transparent)]