This commit is contained in:
Sam Kim
2021-10-14 15:44:33 -04:00
committed by Michael Vines
parent 57103c515b
commit 6749c45c63
2 changed files with 1 additions and 39 deletions

View File

@ -22,7 +22,7 @@ mod target_arch {
range_proof::RangeProof,
},
curve25519_dalek::{ristretto::CompressedRistretto, scalar::Scalar},
std::convert::{TryFrom, TryInto},
std::convert::TryFrom,
};
impl From<Scalar> for pod::Scalar {
@ -136,30 +136,6 @@ mod target_arch {
}
}
impl From<Option<AESCiphertext>> for pod::OptionAESCiphertext {
fn from(ct: Option<AESCiphertext>) -> Self {
let mut buf = [0_u8; 17];
match ct {
Some(ct) => {
buf[0] = 1_u8;
buf[1..].copy_from_slice(&ct.0);
Self(buf)
},
None => Self(buf),
}
}
}
impl From<pod::OptionAESCiphertext> for Option<AESCiphertext> {
fn from(ct: pod::OptionAESCiphertext) -> Self {
if ct.0[0] == 0 {
None
} else {
Some(AESCiphertext(ct.0[1..17].try_into().unwrap()))
}
}
}
impl TryFrom<RangeProof> for pod::RangeProof64 {
type Error = ProofError;

View File

@ -81,17 +81,3 @@ impl fmt::Debug for AESCiphertext {
}
}
/// Temporary serialization of Option<AESCiphertext>
#[derive(Clone, Copy, Pod, Zeroable, PartialEq)]
#[repr(transparent)]
pub struct OptionAESCiphertext(pub [u8; 17]);
impl fmt::Debug for OptionAESCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.0[0] == 1_u8 {
write!(f, "Some({:?})", &self.0[1..17])
} else {
write!(f, "None")
}
}
}