update applying pending balance for aes ciphertext
This commit is contained in:
@ -47,7 +47,7 @@ impl AESKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AESCiphertext([u8; 16]);
|
pub struct AESCiphertext(pub [u8; 16]);
|
||||||
impl AESCiphertext {
|
impl AESCiphertext {
|
||||||
pub fn decrypt(&self, sk: &AESKey) -> u64 {
|
pub fn decrypt(&self, sk: &AESKey) -> u64 {
|
||||||
AES::decrypt(sk, self)
|
AES::decrypt(sk, self)
|
||||||
|
@ -22,7 +22,7 @@ mod target_arch {
|
|||||||
range_proof::RangeProof,
|
range_proof::RangeProof,
|
||||||
},
|
},
|
||||||
curve25519_dalek::{ristretto::CompressedRistretto, scalar::Scalar},
|
curve25519_dalek::{ristretto::CompressedRistretto, scalar::Scalar},
|
||||||
std::convert::TryFrom,
|
std::convert::{TryFrom, TryInto},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl From<Scalar> for pod::Scalar {
|
impl From<Scalar> for pod::Scalar {
|
||||||
@ -136,6 +136,30 @@ 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 {
|
impl TryFrom<RangeProof> for pod::RangeProof64 {
|
||||||
type Error = ProofError;
|
type Error = ProofError;
|
||||||
|
|
||||||
|
@ -80,3 +80,18 @@ impl fmt::Debug for AESCiphertext {
|
|||||||
write!(f, "{:?}", self.0)
|
write!(f, "{:?}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user