zk-token-sdk: implement Display for ciphertexts (#26755)

This commit is contained in:
samkim-crypto 2022-07-23 21:59:40 +09:00 committed by GitHub
parent 3396d4eccd
commit 700da0fc83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -15,7 +15,7 @@ use {
signature::Signature,
signer::{Signer, SignerError},
},
std::convert::TryInto,
std::{convert::TryInto, fmt},
zeroize::Zeroize,
};
@ -129,6 +129,12 @@ impl AeCiphertext {
}
}
impl fmt::Display for AeCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.to_bytes()))
}
}
#[cfg(test)]
mod tests {
use {

View File

@ -457,6 +457,12 @@ impl ElGamalCiphertext {
}
}
impl fmt::Display for ElGamalCiphertext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", base64::encode(self.to_bytes()))
}
}
impl<'a, 'b> Add<&'b ElGamalCiphertext> for &'a ElGamalCiphertext {
type Output = ElGamalCiphertext;