Skip to content

Commit

Permalink
zk-token-sdk: implement Display for ciphertexts (solana-labs#26755)
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto authored Jul 23, 2022
1 parent 3396d4e commit 700da0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zk-token-sdk/src/encryption/auth_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
signature::Signature,
signer::{Signer, SignerError},
},
std::convert::TryInto,
std::{convert::TryInto, fmt},
zeroize::Zeroize,
};

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions zk-token-sdk/src/encryption/elgamal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 700da0f

Please sign in to comment.